module  Core
(
    input   wire                clk,
    input   wire                rstn,
    //
    input   wire                mei,
    input   wire                msi,
    input   wire                mti,
    output  wire    [07:00]     byte_en,
    //
    input   wire                WB_ACKi,
    input   wire    [63:00]     WB_DATi,
    output  wire    [63:00]     WB_ADRo,
    output  wire    [63:00]     WB_DATo,
    output  wire                WB_WEo ,
    output  wire                WB_CYCo
); 
//----------------------------wires----------------------------------  
    // piplineCtrlUnit
    wire                        pcu_jal_flag_i;
    wire                        pcu_jalr_flag_i;
    wire                        pcu_branch_flag_i;
    wire                        pcu_branch_predic_fault_i;
    wire                        pcu_lsu_flag_i;
    wire                        pcu_lsu_done_i;
    wire                        pcu_wfi_flag_i;
    wire                        pcu_exc_irq_flag_i;
    wire                        pcu_mret_flag_i;
    wire                        pcu_data_raw_depcy_i;
    wire                        pcu_PC_HOLD_o;
    wire                        pcu_IFF_IFS_FLUSH_o;
    wire                        pcu_IFF_IFS_STALL_o;
    wire                        pcu_IFS_IDF_FLUSH_o;
    wire                        pcu_IFS_IDF_STALL_o;
    wire                        pcu_IDF_IDS_FLUSH_o;
    wire                        pcu_IDF_IDS_STALL_o;
    wire                        pcu_IDS_EX_FLUSH_o;
    wire                        pcu_IDS_EX_STALL_o;
    wire                        pcu_EX_MEM_FLUSH_o;
    wire                        pcu_EX_MEM_STALL_o;
    wire                        pcu_MEM_WB_FLUSH_o;
    wire                        pcu_MEM_WB_STALL_o;

    // csr
    wire            [63:00]     csr_pc_i;
    wire            [31:00]     csr_instr_i;
    wire                        csr_bubble_flag_i;
    wire            [11:00]     csr_id_i;
    wire                        csr_write_back_en_i;
    wire            [11:00]     csr_write_back_id_i;
    wire            [63:00]     csr_write_back_data_i;
    wire                        csr_mei_flag_i;
    wire                        csr_msi_flag_i;
    wire                        csr_mti_flag_i;
    wire                        csr_irq_flag_i;
    wire                        csr_instr_addr_misalig_i;
    wire                        csr_instr_acc_fault_i;
    wire                        csr_illegal_instr_i;
    wire                        csr_ebreak_i;
    wire                        csr_load_addr_misalig_i;
    wire                        csr_load_acc_fault_i;
    wire                        csr_store_addr_misalig_i;
    wire                        csr_store_acc_fault_i;
    wire                        csr_ecall_i;
    wire                        csr_mret_i;
    wire                        csr_exc_flag_i;

    wire            [63:00]     csr_mstatus_o;
    wire            [63:00]     csr_mie_o;
    wire            [63:00]     csr_mtvec_o;
    wire            [63:00]     csr_mepc_o;
    wire            [63:00]     csr_output_o;
    // bpu
    wire            [31:00]     bpu_instr_i;
    wire            [63:00]     bpu_pc_i;
    wire                        bpu_instr_jalr_i;
    wire            [63:00]     bpu_jalr_base_addr_i;
    wire            [63:00]     bpu_jalr_offset_i;
    wire                        bpu_branch_predic_fault_i;
    wire                        bpu_jal_flag_o;
    wire                        bpu_jalr_flag_o;
    wire                        bpu_branch_flag_o;                        
    wire                        bpu_branch_predic_res_o; 
    wire            [63:00]     bpu_branch_reserve_addr_o;                                             
    wire            [63:00]     bpu_jump_addr_o;

    //  IFU
    wire                        IFF_IFS_FLUSH_i;
    wire                        IFF_IFS_STALL_i;
    wire                        ifu_pc_hold_i;
    wire                        ifu_jalr_flag_i;
    wire                        ifu_jal_flag_i;
    wire                        ifu_branch_flag_i;
    wire            [63:00]     ifu_jump_addr_i;
    wire                        ifu_branch_predic_fault_i;
    wire            [63:00]     ifu_branch_reserve_addr_i;
    wire                        ifu_exc_irq_flag_i;
    wire            [63:00]     ifu_exc_irq_srv_prog_addr_i;
    wire                        ifu_mret_i;
    wire            [63:00]     ifu_mepc_i;
    wire            [63:00]     ifu_fetch_addr_o;
    wire            [31:00]     ifu_instr_i;
    wire                        ifu_bubble_flag_o;
    wire            [63:00]     ifu_instr_pc_o;
    wire            [31:00]     ifu_instr_o;
    //  itcm
    wire            [63:00]     itcm_pc_i;
    wire            [31:00]     itcm_instr_o;
                        

    // IFS_IDF
    wire                        IFS_IDF_FLUSH_i;
    wire                        IFS_IDF_STALL_i;
    wire            [63:00]     IFS_IDF_PC_i;               
    wire            [31:00]     IFS_IDF_INSTR_i;            
    wire                        IFS_IDF_BUBBLE_FLAG_i;
    wire                        IFS_IDF_BRANCH_PREDIC_RES_i;
    wire            [63:00]     IFS_IDF_BRANCH_RESERVE_ADDR_i;
    wire            [63:00]     IFS_IDF_PC_o;               
    wire            [31:00]     IFS_IDF_INSTR_o; 
    wire                        IFS_IDF_BUBBLE_FLAG_o;
    wire            [63:00]     IFS_IDF_BRANCH_RESERVE_ADDR_o;
    wire                        IFS_IDF_BRANCH_PREDIC_RES_o;

    //  -----------------------------IDF---------------------- 
    wire                [31:00]     idf_instr_i;
    wire                [04:00]     idf_gpr_ids_rd_i;
    wire                [04:00]     idf_gpr_ex_rd_i;
    wire                [04:00]     idf_gpr_mem_rd_i;
    wire                [04:00]     idf_gpr_wb_rd_i;
    wire                [11:00]     idf_csr_ids_rd_i;
    wire                [11:00]     idf_csr_ex_rd_i;
    wire                [11:00]     idf_csr_mem_rd_i;
    wire                [11:00]     idf_csr_wb_rd_i;
    wire                            idf_gpr_write_back_en_i;
    wire                [04:00]     idf_gpr_write_back_id_i;
    wire                [63:00]     idf_gpr_write_back_data_i;
    wire                            idf_instr_load_o;
    wire                            idf_instr_load_fp_o;
    wire                            idf_instr_misc_mem_o;
    wire                            idf_instr_op_imm_o;
    wire                            idf_instr_auipc_o;
    wire                            idf_instr_op_imm_32_o;
    wire                            idf_instr_store_o;
    wire                            idf_instr_store_fp_o;
    wire                            idf_instr_amo_o;
    wire                            idf_instr_op_o;
    wire                            idf_instr_lui_o;
    wire                            idf_instr_op_32_o;
    wire                            idf_instr_madd_o;
    wire                            idf_instr_msub_o;
    wire                            idf_instr_nmsub_o;
    wire                            idf_instr_nmadd_o;
    wire                            idf_instr_op_fp_o;
    wire                            idf_instr_branch_o;
    wire                            idf_instr_jalr_o;
    wire                            idf_instr_jal_o;
    wire                            idf_instr_system_o;
    wire                [02:00]     idf_funct3_o;
    wire                [06:00]     idf_funct7_o;
    wire                [04:00]     idf_funct5_o;
    wire                [11:00]     idf_funct12_o;
    wire                [10:00]     idf_alu_op_o;
    wire                [08:00]     idf_mdu_op_o;
    wire                [01:00]     idf_alu_shift_mode_o;
    wire                [03:00]     idf_disp_target_o;
    wire                            idf_operand1_sel_o;
    wire                            idf_operand2_sel_o;
    wire                            idf_rs1_bypassdata_sel_o     ;
    wire                            idf_rs2_bypassdata_sel_o     ;
    wire                            idf_csr_bypassdata_sel_o     ;
    wire                            idf_rs1_bypassdata_ex_sel_o  ;
    wire                            idf_rs1_bypassdata_mem_sel_o ;
    wire                            idf_rs1_bypassdata_wb_sel_o  ;
    wire                            idf_rs2_bypassdata_ex_sel_o  ;
    wire                            idf_rs2_bypassdata_mem_sel_o ;
    wire                            idf_rs2_bypassdata_wb_sel_o  ;
    wire                            idf_csr_bypassdata_ex_sel_o  ;
    wire                            idf_csr_bypassdata_mem_sel_o ;
    wire                            idf_csr_bypassdata_wb_sel_o  ;
    wire                            idf_data_raw_depcy_o;
    wire                            idf_gpr_write_back_en_o;
    wire                [04:00]     idf_gpr_write_back_id_o;
    wire                            idf_gpr_write_back_from_alu_o;
    wire                            idf_gpr_write_back_from_lsu_o;
    wire                            idf_gpr_write_back_from_mdu_o;
    wire                [11:00]     idf_csr_id_o;
    wire                            idf_csr_write_back_en_o;
    wire                [11:00]     idf_csr_write_back_id_o;
    wire                [63:00]     idf_imm_o;
    wire                [63:00]     idf_jalr_offset_o;
    wire                            idf_illegal_instr_flag_o;
    wire                [63:00]     idf_gpr_output1_o;
    wire                [63:00]     idf_gpr_output2_o;
    //  ----------------------------IDF/IDS------------------------
    wire                            IDF_IDS_FLUSH_i;
    wire                            IDF_IDS_STALL_i;
    wire                            IDF_IDS_BUBBLE_FLAG_i;
    wire                            IDF_IDS_ILLEGAL_INSTR_FLAG_i;
    wire                [63:00]     IDF_IDS_PC_i;
    wire                [31:00]     IDF_IDS_INSTR_i;
    wire                [02:00]     IDF_IDS_FUNCT3_i;
    wire                            IDF_IDS_INSTR_JALR_i;
    wire                            IDF_IDS_INSTR_LOAD_i;
    wire                            IDF_IDS_INSTR_STORE_i;
    wire                            IDF_IDS_INSTR_SYSTEM_i;
    wire                            IDF_IDS_INSTR_BRANCH_i;
    wire                            IDF_IDS_BRANCH_PREDIC_RES_i;
    wire                [63:00]     IDF_IDS_BRANCH_RESERVE_ADDR_i;
    wire                            IDF_IDS_OPERAND1_SEL_i;
    wire                            IDF_IDS_OPERAND2_SEL_i;
    wire                [63:00]     IDF_IDS_CSR_OUTPUT_i;
    wire                [63:00]     IDF_IDS_GPR_OUTPUT1_i;
    wire                [63:00]     IDF_IDS_GPR_OUTPUT2_i;
    wire                [63:00]     IDF_IDS_IMM_i;
    wire                [63:00]     IDF_IDS_GPR_BYPASSDATA_EX_i;
    wire                [63:00]     IDF_IDS_GPR_BYPASSDATA_MEM_i;
    wire                [63:00]     IDF_IDS_GPR_BYPASSDATA_WB_i;
    wire                [63:00]     IDF_IDS_CSR_BYPASSDATA_EX_i;
    wire                [63:00]     IDF_IDS_CSR_BYPASSDATA_MEM_i;
    wire                [63:00]     IDF_IDS_CSR_BYPASSDATA_WB_i;

    wire                            IDF_IDS_RS1_BYPASSDATA_SEL_i    ;
    wire                            IDF_IDS_RS2_BYPASSDATA_SEL_i    ;
    wire                            IDF_IDS_CSR_BYPASSDATA_SEL_i    ;
    wire                            IDF_IDS_RS1_BYPASSDATA_EX_SEL_i ;
    wire                            IDF_IDS_RS1_BYPASSDATA_MEM_SEL_i;
    wire                            IDF_IDS_RS1_BYPASSDATA_WB_SEL_i ;
    wire                            IDF_IDS_RS2_BYPASSDATA_EX_SEL_i ;
    wire                            IDF_IDS_RS2_BYPASSDATA_MEM_SEL_i;
    wire                            IDF_IDS_RS2_BYPASSDATA_WB_SEL_i ;
    wire                            IDF_IDS_CSR_BYPASSDATA_EX_SEL_i ;
    wire                            IDF_IDS_CSR_BYPASSDATA_MEM_SEL_i;
    wire                            IDF_IDS_CSR_BYPASSDATA_WB_SEL_i ;

    wire                            IDF_IDS_GPR_WRITE_BACK_EN_i;
    wire                [04:00]     IDF_IDS_GPR_WRITE_BACK_ID_i;
    wire                            IDF_IDS_GPR_WRITE_BACK_FROM_ALU_i;
    wire                            IDF_IDS_GPR_WRITE_BACK_FROM_LSU_i;
    wire                            IDF_IDS_GPR_WRITE_BACK_FROM_MDU_i;
    wire                [03:00]     IDF_IDS_DISP_TARGET_i;
    wire                            IDF_IDS_CSR_WRITE_BACK_EN_i;
    wire                [11:00]     IDF_IDS_CSR_WRITE_BACK_ID_i;
    wire                [01:00]     IDF_IDS_ALU_SHIFT_MODE_i;
    wire                [10:00]     IDF_IDS_ALU_OP_i;
    wire                [08:00]     IDF_IDS_MDU_OP_i;
    wire                [63:00]     IDF_IDS_JALR_OFFSET_i;

    wire                            IDF_IDS_BUBBLE_FLAG_o;
    wire                            IDF_IDS_ILLEGAL_INSTR_FLAG_o;
    wire                [63:00]     IDF_IDS_PC_o;
    wire                [02:00]     IDF_IDS_FUNCT3_o;
    wire                [31:00]     IDF_IDS_INSTR_o;
    wire                            IDF_IDS_INSTR_JALR_o;
    wire                            IDF_IDS_INSTR_LOAD_o;
    wire                            IDF_IDS_INSTR_STORE_o;
    wire                            IDF_IDS_INSTR_SYSTEM_o;
    wire                            IDF_IDS_INSTR_BRANCH_o;
    wire                            IDF_IDS_BRANCH_PREDIC_RES_o;
    wire                [63:00]     IDF_IDS_BRANCH_RESERVE_ADDR_o;
    wire                            IDF_IDS_OPERAND1_SEL_o;
    wire                            IDF_IDS_OPERAND2_SEL_o;
    wire                [63:00]     IDF_IDS_CSR_OUTPUT_o;
    wire                [63:00]     IDF_IDS_GPR_OUTPUT1_o;
    wire                [63:00]     IDF_IDS_GPR_OUTPUT2_o;
    wire                [63:00]     IDF_IDS_IMM_o;
    wire                [63:00]     IDF_IDS_GPR_BYPASSDATA_EX_o;
    wire                [63:00]     IDF_IDS_GPR_BYPASSDATA_MEM_o;
    wire                [63:00]     IDF_IDS_GPR_BYPASSDATA_WB_o;
    wire                [63:00]     IDF_IDS_CSR_BYPASSDATA_EX_o;
    wire                [63:00]     IDF_IDS_CSR_BYPASSDATA_MEM_o;
    wire                [63:00]     IDF_IDS_CSR_BYPASSDATA_WB_o;

    wire                            IDF_IDS_RS1_BYPASSDATA_SEL_o    ;
    wire                            IDF_IDS_RS2_BYPASSDATA_SEL_o    ;
    wire                            IDF_IDS_CSR_BYPASSDATA_SEL_o    ;
    wire                            IDF_IDS_RS1_BYPASSDATA_EX_SEL_o ;
    wire                            IDF_IDS_RS1_BYPASSDATA_MEM_SEL_o;
    wire                            IDF_IDS_RS1_BYPASSDATA_WB_SEL_o ;
    wire                            IDF_IDS_RS2_BYPASSDATA_EX_SEL_o ;
    wire                            IDF_IDS_RS2_BYPASSDATA_MEM_SEL_o;
    wire                            IDF_IDS_RS2_BYPASSDATA_WB_SEL_o ;
    wire                            IDF_IDS_CSR_BYPASSDATA_EX_SEL_o ;
    wire                            IDF_IDS_CSR_BYPASSDATA_MEM_SEL_o;
    wire                            IDF_IDS_CSR_BYPASSDATA_WB_SEL_o ;

    wire                            IDF_IDS_GPR_WRITE_BACK_EN_o;
    wire                [04:00]     IDF_IDS_GPR_WRITE_BACK_ID_o;
    wire                            IDF_IDS_GPR_WRITE_BACK_FROM_ALU_o;
    wire                            IDF_IDS_GPR_WRITE_BACK_FROM_LSU_o;
    wire                            IDF_IDS_GPR_WRITE_BACK_FROM_MDU_o;
    wire                            IDF_IDS_CSR_WRITE_BACK_EN_o;
    wire                [11:00]     IDF_IDS_CSR_WRITE_BACK_ID_o;
    wire                [03:00]     IDF_IDS_DISP_TARGET_o;
    wire                [01:00]     IDF_IDS_ALU_SHIFT_MODE_o;
    wire                [10:00]     IDF_IDS_ALU_OP_o;
    wire                [08:00]     IDF_IDS_MDU_OP_o;
    wire                [63:00]     IDF_IDS_JALR_OFFSET_o;
    //  ------------------------------IDS---------------------
    wire            [63:00]     ids_pc_i;
    wire            [63:00]     ids_imm_i;
    wire            [01:00]     ids_alu_shift_mode_i;
    wire            [10:00]     ids_alu_op_i;
    wire                        ids_operand1_sel_i;
    wire                        ids_operand2_sel_i;
    wire                        ids_rs1_bypassdata_sel_i;
    wire                        ids_rs2_bypassdata_sel_i;
    wire                        ids_csr_bypassdata_sel_i;
    wire                        ids_rs1_bypassdata_ex_sel_i;
    wire                        ids_rs1_bypassdata_mem_sel_i;
    wire                        ids_rs1_bypassdata_wb_sel_i;
    wire                        ids_rs2_bypassdata_ex_sel_i;
    wire                        ids_rs2_bypassdata_mem_sel_i;
    wire                        ids_rs2_bypassdata_wb_sel_i;
    wire                        ids_csr_bypassdata_ex_sel_i;
    wire                        ids_csr_bypassdata_mem_sel_i;
    wire                        ids_csr_bypassdata_wb_sel_i;
    wire            [04:00]     ids_csr_id_i;
    wire            [63:00]     ids_csr_output_i;
    wire            [63:00]     ids_gpr_output1_i;
    wire            [63:00]     ids_gpr_output2_i;
    wire            [63:00]     ids_gpr_bypassdata_ex_i;
    wire            [63:00]     ids_gpr_bypassdata_mem_i;
    wire            [63:00]     ids_gpr_bypassdata_wb_i;
    wire            [63:00]     ids_csr_bypassdata_ex_i;
    wire            [63:00]     ids_csr_bypassdata_mem_i;
    wire            [63:00]     ids_csr_bypassdata_wb_i;
    wire            [63:00]     ids_operand1_o;
    wire            [63:00]     ids_operand2_o;
    wire            [63:00]     ids_rs1_data_o;
    wire            [63:00]     ids_rs2_data_o;
    wire            [63:00]     ids_csr_data_o;
    wire            [63:00]     ids_shift2_o;
    wire            [32:00]     ids_add_res_l_o  ;
    wire            [31:00]     ids_add_res_h_o  ;
    wire            [32:00]     ids_sub_res_l_o  ;   
    wire            [31:00]     ids_sub_res_h_o  ;
    wire                        ids_subu_res_l_o ;
    wire            [31:00]     ids_subu_res_h_o ;
    //--------------------------IDS/EX---------------------------------
    wire                            IDS_EX_FLUSH_i;
    wire                            IDS_EX_STALL_i;
    wire                            IDS_EX_BUBBLE_FLAG_i;
    wire                            IDS_EX_ILLEGAL_INSTR_FLAG_i;
    wire                [63:00]     IDS_EX_PC_i;
    wire                [31:00]     IDS_EX_INSTR_i;
    wire                [02:00]     IDS_EX_FUNCT3_i;
    wire                            IDS_EX_INSTR_JALR_i;
    wire                            IDS_EX_INSTR_LOAD_i;
    wire                            IDS_EX_INSTR_STORE_i;
    wire                            IDS_EX_INSTR_SYSTEM_i;
    wire                            IDS_EX_INSTR_BRANCH_i;
    wire                            IDS_EX_BRANCH_PREDIC_RES_i;
    wire                [63:00]     IDS_EX_BRANCH_RESERVE_ADDR_i;
    wire                            IDS_EX_GPR_WRITE_BACK_EN_i;
    wire                [04:00]     IDS_EX_GPR_WRITE_BACK_ID_i;
    wire                            IDS_EX_GPR_WRITE_BACK_FROM_ALU_i;
    wire                            IDS_EX_GPR_WRITE_BACK_FROM_LSU_i;
    wire                            IDS_EX_GPR_WRITE_BACK_FROM_MDU_i;
    wire                [03:00]     IDS_EX_DISP_TARGET_i;
    wire                            IDS_EX_CSR_WRITE_BACK_EN_i;
    wire                [11:00]     IDS_EX_CSR_WRITE_BACK_ID_i;
    wire                [01:00]     IDS_EX_ALU_SHIFT_MODE_i;
    wire                [10:00]     IDS_EX_ALU_OP_i;
    wire                [08:00]     IDS_EX_MDU_OP_i;
    wire                [63:00]     IDS_EX_SHIFT2_i;
    wire                [32:00]     IDS_EX_ADD_RES_L_i   ;
    wire                [31:00]     IDS_EX_ADD_RES_H_i   ;
    wire                [32:00]     IDS_EX_SUB_RES_L_i   ;   
    wire                [31:00]     IDS_EX_SUB_RES_H_i   ;
    wire                            IDS_EX_SUBU_RES_L_i  ;
    wire                [31:00]     IDS_EX_SUBU_RES_H_i  ;
    wire                [63:00]     IDS_EX_OPERAND1_i;
    wire                [63:00]     IDS_EX_OPERAND2_i;
    wire                [63:00]     IDS_EX_RS1_DATA_i;
    wire                [63:00]     IDS_EX_RS2_DATA_i;
    wire                [63:00]     IDS_EX_JALR_OFFSET_i;
    wire                [63:00]     IDS_EX_CSR_DATA_i;
    wire                            IDS_EX_BUBBLE_FLAG_o;
    wire                            IDS_EX_ILLEGAL_INSTR_FLAG_o;
    wire                [63:00]     IDS_EX_PC_o;
    wire                [02:00]     IDS_EX_FUNCT3_o;
    wire                [31:00]     IDS_EX_INSTR_o;
    wire                            IDS_EX_INSTR_JALR_o;
    wire                            IDS_EX_INSTR_LOAD_o;
    wire                            IDS_EX_INSTR_STORE_o;
    wire                            IDS_EX_INSTR_SYSTEM_o;
    wire                            IDS_EX_INSTR_BRANCH_o;
    wire                            IDS_EX_BRANCH_PREDIC_RES_o;
    wire                [63:00]     IDS_EX_BRANCH_RESERVE_ADDR_o;
    wire                            IDS_EX_GPR_WRITE_BACK_EN_o;
    wire                [04:00]     IDS_EX_GPR_WRITE_BACK_ID_o;
    wire                            IDS_EX_GPR_WRITE_BACK_FROM_ALU_o;
    wire                            IDS_EX_GPR_WRITE_BACK_FROM_LSU_o;
    wire                            IDS_EX_GPR_WRITE_BACK_FROM_MDU_o;
    wire                            IDS_EX_CSR_WRITE_BACK_EN_o;
    wire                [11:00]     IDS_EX_CSR_WRITE_BACK_ID_o;
    wire                [03:00]     IDS_EX_DISP_TARGET_o;
    wire                [01:00]     IDS_EX_ALU_SHIFT_MODE_o;
    wire                [10:00]     IDS_EX_ALU_OP_o;
    wire                [08:00]     IDS_EX_MDU_OP_o;
    wire                [63:00]     IDS_EX_SHIFT2_o;
    wire                [32:00]     IDS_EX_ADD_RES_L_o   ;
    wire                [31:00]     IDS_EX_ADD_RES_H_o   ;
    wire                [32:00]     IDS_EX_SUB_RES_L_o   ;   
    wire                [31:00]     IDS_EX_SUB_RES_H_o   ;
    wire                            IDS_EX_SUBU_RES_L_o  ;
    wire                [31:00]     IDS_EX_SUBU_RES_H_o  ;
    wire                [63:00]     IDS_EX_OPERAND1_o;
    wire                [63:00]     IDS_EX_OPERAND2_o;
    wire                [63:00]     IDS_EX_RS1_DATA_o;
    wire                [63:00]     IDS_EX_RS2_DATA_o;
    wire                [63:00]     IDS_EX_JALR_OFFSET_o;
    wire                [63:00]     IDS_EX_CSR_DATA_o;
    //  EXU
    wire                        exu_instr_branch_i;
    wire                        exu_branch_predic_res_i;
    wire            [02:00]     exu_funct3_i;
    wire            [03:00]     exu_disp_target_i;
    wire            [10:00]     exu_alu_op_i;
    wire            [01:00]     exu_alu_shift_mode_i;
    wire            [08:00]     exu_mdu_op_i;
    wire            [63:00]     exu_shift2_i;
    wire            [32:00]     exu_add_res_l_i  ;
    wire            [31:00]     exu_add_res_h_i  ;
    wire            [32:00]     exu_sub_res_l_i  ;   
    wire            [31:00]     exu_sub_res_h_i  ;
    wire                        exu_subu_res_l_i ;
    wire            [31:00]     exu_subu_res_h_i ;  
    wire            [63:00]     exu_operand1_i;
    wire            [63:00]     exu_operand2_i;
    wire            [63:00]     exu_csr_data_i;
    wire                        exu_branch_predic_fault_o;
    wire            [63:00]     exu_mdu_output_o;
    wire            [63:00]     exu_alu_output_o;
    wire            [63:00]     exu_csr_write_back_data_o;
    //  EX/MEM
    wire                        EX_MEM_FLUSH_i;
    wire                        EX_MEM_STALL_i;
    wire                        EX_MEM_BUBBLE_FLAG_i;
    wire                        EX_MEM_ILLEGAL_INSTR_FLAG_i;
    wire            [31:00]     EX_MEM_INSTR_i;
    wire            [63:00]     EX_MEM_PC_i;
    wire            [02:00]     EX_MEM_FUNCT3_i;
    wire                        EX_MEM_INSTR_LOAD_i;
    wire                        EX_MEM_INSTR_STORE_i;
    wire                        EX_MEM_INSTR_SYSTEM_i;
    wire                        EX_MEM_GPR_WRITE_BACK_EN_i;
    wire            [04:00]     EX_MEM_GPR_WRITE_BACK_ID_i;
    wire                        EX_MEM_GPR_WRITE_BACK_FROM_ALU_i;
    wire                        EX_MEM_GPR_WRITE_BACK_FROM_LSU_i;
    wire                        EX_MEM_GPR_WRITE_BACK_FROM_MDU_i;
    wire                        EX_MEM_CSR_WRITE_BACK_EN_i;
    wire            [11:00]     EX_MEM_CSR_WRITE_BACK_ID_i;
    wire            [63:00]     EX_MEM_RS2_DATA_i;
    wire            [63:00]     EX_MEM_ALU_OUTPUT_i;
    wire            [63:00]     EX_MEM_MDU_OUTPUT_i;
    wire            [63:00]     EX_MEM_CSR_WRITE_BACK_DATA_i;
    wire                        EX_MEM_BUBBLE_FLAG_o;
    wire                        EX_MEM_ILLEGAL_INSTR_FLAG_o;
    wire            [31:00]     EX_MEM_INSTR_o;
    wire            [63:00]     EX_MEM_PC_o;
    wire            [02:00]     EX_MEM_FUNCT3_o;
    wire                        EX_MEM_INSTR_LOAD_o;
    wire                        EX_MEM_INSTR_STORE_o;
    wire                        EX_MEM_INSTR_SYSTEM_o;
    wire                        EX_MEM_GPR_WRITE_BACK_EN_o;
    wire            [04:00]     EX_MEM_GPR_WRITE_BACK_ID_o;
    wire                        EX_MEM_GPR_WRITE_BACK_FROM_ALU_o;
    wire                        EX_MEM_GPR_WRITE_BACK_FROM_LSU_o;
    wire                        EX_MEM_GPR_WRITE_BACK_FROM_MDU_o;
    wire                        EX_MEM_CSR_WRITE_BACK_EN_o;
    wire            [11:00]     EX_MEM_CSR_WRITE_BACK_ID_o;
    wire            [63:00]     EX_MEM_RS2_DATA_o;
    wire            [63:00]     EX_MEM_ALU_OUTPUT_o;
    wire            [63:00]     EX_MEM_MDU_OUTPUT_o;
    wire            [63:00]     EX_MEM_CSR_WRITE_BACK_DATA_o;
    // -----------------------------MEM------------------
    // edu
    wire            [31:00]     edu_instr_i;
    wire            [01:00]     edu_pc_i;
    wire            [02:00]     edu_funct3_i;
    
    wire                        edu_instr_system_i;
    wire                        edu_instr_load_i;
    wire                        edu_instr_store_i;
    wire            [02:00]     edu_mem_addr_i;
    wire                        edu_illegal_instr_flag_i;
    wire                        edu_instr_acc_fault_i;
    wire                        edu_load_acc_fault_i;
    wire                        edu_store_acc_fault_i;
    wire                        edu_mret_flag_o;
    wire                        edu_wfi_flag_o;
    wire                        edu_exc_flag_o;
    wire                        edu_instr_addr_misalig_o;
    wire                        edu_instr_acc_fault_o;
    wire                        edu_illegal_instr_o;
    wire                        edu_ebreak_o;
    wire                        edu_load_addr_misalig_o;
    wire                        edu_load_acc_fault_o;
    wire                        edu_store_addr_misalig_o;
    wire                        edu_store_acc_fault_o;
    wire                        edu_ecall_o;

    //  LSU
    wire                        lsu_flush_i;
    wire                        lsu_exc_irq_flag_i;
    wire                        lsu_instr_load_i;
    wire                        lsu_instr_store_i;
    wire            [02:0]      lsu_funct3_i;
    wire            [63:0]      lsu_mem_addr_i;
    wire            [63:0]      lsu_store_data_i;
    wire                        lsu_done_o;
    wire                        lsu_flag_o;
    wire            [63:0]      lsu_load_data_o;


    // MEM_WB
    wire                        MEM_WB_FLUSH_i;
    wire                        MEM_WB_STALL_i;
    wire                        MEM_WB_BUBBLE_FLAG_i;
    wire            [31:00]     MEM_WB_INSTR_i;
    wire            [63:00]     MEM_WB_PC_i;
    wire                        MEM_WB_GPR_WRITE_BACK_EN_i;
    wire            [04:00]     MEM_WB_GPR_WRITE_BACK_ID_i;
    wire                        MEM_WB_GPR_WRITE_BACK_FROM_ALU_i;
    wire                        MEM_WB_GPR_WRITE_BACK_FROM_LSU_i;
    wire                        MEM_WB_GPR_WRITE_BACK_FROM_MDU_i;
    wire                        MEM_WB_CSR_WRITE_BACK_EN_i;
    wire            [11:00]     MEM_WB_CSR_WRITE_BACK_ID_i;
    wire            [63:00]     MEM_WB_ALU_OUTPUT_i;
    wire            [63:00]     MEM_WB_LSU_OUTPUT_i;
    wire            [63:00]     MEM_WB_MDU_OUTPUT_i;
    wire            [63:00]     MEM_WB_CSR_WRITE_BACK_DATA_i;
    wire                        MEM_WB_INSTR_ADDR_MISALIG_i;
    wire                        MEM_WB_INSTR_ACC_FAULT_i;
    wire                        MEM_WB_ILLEGAL_INSTR_i;
    wire                        MEM_WB_EBREAK_i;
    wire                        MEM_WB_LOAD_ADDR_MISALIG_i;
    wire                        MEM_WB_LOAD_ACC_FAULT_i;
    wire                        MEM_WB_STORE_ADDR_MISALIG_i;
    wire                        MEM_WB_STORE_ACC_FAULT_i;
    wire                        MEM_WB_ECALL_i;
    wire                        MEM_WB_MRET_FLAG_i;
    wire                        MEM_WB_WFI_FLAG_i;
    wire                        MEM_WB_EXC_FLAG_i;
    wire                        MEM_WB_MEI_i;
    wire                        MEM_WB_MSI_i;
    wire                        MEM_WB_MTI_i;
    wire                        MEM_WB_BUBBLE_FLAG_o;
    wire            [31:00]     MEM_WB_INSTR_o;
    wire            [63:00]     MEM_WB_PC_o;
    wire                        MEM_WB_GPR_WRITE_BACK_EN_o;
    wire            [04:00]     MEM_WB_GPR_WRITE_BACK_ID_o;
    wire                        MEM_WB_GPR_WRITE_BACK_FROM_ALU_o;
    wire                        MEM_WB_GPR_WRITE_BACK_FROM_LSU_o;
    wire                        MEM_WB_GPR_WRITE_BACK_FROM_MDU_o;
    wire                        MEM_WB_CSR_WRITE_BACK_EN_o;
    wire            [11:00]     MEM_WB_CSR_WRITE_BACK_ID_o;
    wire            [63:00]     MEM_WB_ALU_OUTPUT_o;
    wire            [63:00]     MEM_WB_LSU_OUTPUT_o;
    wire            [63:00]     MEM_WB_MDU_OUTPUT_o;
    wire            [63:00]     MEM_WB_CSR_WRITE_BACK_DATA_o;
    wire                        MEM_WB_INSTR_ADDR_MISALIG_o;
    wire                        MEM_WB_INSTR_ACC_FAULT_o;
    wire                        MEM_WB_ILLEGAL_INSTR_o;
    wire                        MEM_WB_EBREAK_o;
    wire                        MEM_WB_LOAD_ADDR_MISALIG_o;
    wire                        MEM_WB_LOAD_ACC_FAULT_o;
    wire                        MEM_WB_STORE_ADDR_MISALIG_o;
    wire                        MEM_WB_STORE_ACC_FAULT_o;
    wire                        MEM_WB_ECALL_o;
    wire                        MEM_WB_MRET_FLAG_o;
    wire                        MEM_WB_WFI_FLAG_o;
    wire                        MEM_WB_EXC_FLAG_o;
    wire                        MEM_WB_MEI_o;
    wire                        MEM_WB_MSI_o;
    wire                        MEM_WB_MTI_o;
    //  wbu
    //
    wire            [63:00]     wbu_mstatus_i;
    wire            [63:00]     wbu_mie_i;
    wire            [63:00]     wbu_mtvec_i;
    //
    wire                        wbu_mei_flag_i;
    wire                        wbu_msi_flag_i;
    wire                        wbu_mti_flag_i;
    wire                        wbu_instr_addr_misalig_i;
    wire                        wbu_instr_acc_fault_i;
    wire                        wbu_illegal_instr_i;
    wire                        wbu_ebreak_i;
    wire                        wbu_load_addr_misalig_i;
    wire                        wbu_load_acc_fault_i;
    wire                        wbu_store_addr_misalig_i;
    wire                        wbu_store_acc_fault_i;
    wire                        wbu_ecall_i;
    wire                        wbu_mret_flag_i;
    wire                        wbu_wfi_flag_i;
    wire                        wbu_exc_flag_i;

    wire                        wbu_mei_flag_o;
    wire                        wbu_msi_flag_o;
    wire                        wbu_mti_flag_o;
    wire                        wbu_irq_flag_o;
    wire                        wbu_instr_addr_misalig_o;
    wire                        wbu_instr_acc_fault_o;
    wire                        wbu_illegal_instr_o;
    wire                        wbu_ebreak_o;
    wire                        wbu_load_addr_misalig_o;
    wire                        wbu_load_acc_fault_o;
    wire                        wbu_store_addr_misalig_o;
    wire                        wbu_store_acc_fault_o;
    wire                        wbu_ecall_o;
    wire                        wbu_mret_flag_o;
    wire                        wbu_wfi_flag_o;
    wire                        wbu_exc_flag_o;
    wire                        wbu_exc_irq_flag_o;
    wire            [63:00]     wbu_exc_irq_srv_prog_addr_o;
    //  gpr
    wire                        wbu_gpr_write_back_en_i;
    wire            [04:00]     wbu_gpr_write_back_id_i;
    wire				        wbu_gpr_write_back_from_alu_i;
	wire				        wbu_gpr_write_back_from_lsu_i;
	wire				        wbu_gpr_write_back_from_mdu_i;
    //  csr
    wire                        wbu_csr_write_back_en_i;
    wire            [11:00]     wbu_csr_write_back_id_i;
    wire            [63:00]     wbu_csr_write_back_data_i;
    //  data
    wire            [63:00]     wbu_alu_output_i;
    wire            [63:00]     wbu_lsu_output_i;
    wire            [63:00]     wbu_mdu_output_i;

    wire                        wbu_gpr_write_back_en_o;
    wire            [04:00]     wbu_gpr_write_back_id_o;
    wire                        wbu_csr_write_back_en_o;
    wire            [11:00]     wbu_csr_write_back_id_o;

    wire            [63:00]     wbu_gpr_write_back_data_o;
    wire            [63:00]     wbu_csr_write_back_data_o;


    


//---------------------------instance-------------------------------- 
    // ------------------------bpu---------------------------
    assign  bpu_instr_i                         =   ifu_instr_o;
    assign  bpu_pc_i                            =   ifu_instr_pc_o;
    assign  bpu_instr_jalr_i                    =   IDS_EX_INSTR_JALR_o; 
    assign  bpu_branch_predic_fault_i           =   exu_branch_predic_fault_o;
    assign  bpu_jalr_offset_i                   =   IDS_EX_JALR_OFFSET_o; 
    assign  bpu_jalr_base_addr_i                =   IDS_EX_RS1_DATA_o;  
                                                                      
    bpu                                                                 bpu
    (
        .instr                                                          (bpu_instr_i),         // IFS_IDF_INSTR_i             
        .pc                                                             (bpu_pc_i),                     
        .jalr_base_addr                                                 (bpu_jalr_base_addr_i),                     
        .instr_jalr                                                     (bpu_instr_jalr_i),
        .jalr_offset                                                    (bpu_jalr_offset_i),
        .branch_predic_fault                                            (bpu_branch_predic_fault_i),
        //
        .jal_flag                                                       (bpu_jal_flag_o),
        .jalr_flag                                                      (bpu_jalr_flag_o),
        .branch_flag                                                    (bpu_branch_flag_o),
        .branch_reserve_addr                                            (bpu_branch_reserve_addr_o),
        //
        .jump_addr                                                      (bpu_jump_addr_o)
    );
    //  pcu
    assign      pcu_jal_flag_i                  =   bpu_jal_flag_o;
    assign      pcu_jalr_flag_i                 =   bpu_jalr_flag_o;
    assign      pcu_branch_flag_i               =   bpu_branch_flag_o;
    assign      pcu_branch_predic_fault_i       =   exu_branch_predic_fault_o;
    assign      pcu_lsu_flag_i                  =   lsu_flag_o;
    assign      pcu_lsu_done_i                  =   lsu_done_o;
    assign      pcu_wfi_flag_i                  =   wbu_wfi_flag_o;
    assign      pcu_exc_irq_flag_i              =   wbu_exc_irq_flag_o;
    assign      pcu_mret_flag_i                 =   wbu_mret_flag_o;
    assign      pcu_data_raw_depcy_i            =   idf_data_raw_depcy_o;
    pcu                                                                 pcu
    (
        .pcu_jal_flag_i                                                 (pcu_jal_flag_i            ) ,
        .pcu_jalr_flag_i                                                (pcu_jalr_flag_i           ) ,
        .pcu_branch_flag_i                                              (pcu_branch_flag_i         ) ,
        .pcu_branch_predic_fault_i                                      (pcu_branch_predic_fault_i ) ,
        .pcu_lsu_flag_i                                                 (pcu_lsu_flag_i            ) ,
        .pcu_lsu_done_i                                                 (pcu_lsu_done_i            ) ,
        .pcu_wfi_flag_i                                                 (pcu_wfi_flag_i            ) ,
        .pcu_exc_irq_flag_i                                             (pcu_exc_irq_flag_i        ) ,
        .pcu_mret_flag_i                                                (pcu_mret_flag_i           ) ,
        .pcu_data_raw_depcy_i                                           (pcu_data_raw_depcy_i),
        .pcu_PC_HOLD_o                                                  (pcu_PC_HOLD_o             ) ,
        .pcu_IFF_IFS_FLUSH_o                                            (pcu_IFF_IFS_FLUSH_o       ) ,
        .pcu_IFF_IFS_STALL_o                                            (pcu_IFF_IFS_STALL_o       ) ,
        .pcu_IFS_IDF_FLUSH_o                                            (pcu_IFS_IDF_FLUSH_o       ) ,
        .pcu_IFS_IDF_STALL_o                                            (pcu_IFS_IDF_STALL_o       ) ,
        .pcu_IDF_IDS_FLUSH_o                                            (pcu_IDF_IDS_FLUSH_o       ) ,
        .pcu_IDF_IDS_STALL_o                                            (pcu_IDF_IDS_STALL_o       ) ,
        .pcu_IDS_EX_FLUSH_o                                             (pcu_IDS_EX_FLUSH_o         ) ,
        .pcu_IDS_EX_STALL_o                                             (pcu_IDS_EX_STALL_o         ) ,
        .pcu_EX_MEM_FLUSH_o                                             (pcu_EX_MEM_FLUSH_o        ) ,
        .pcu_EX_MEM_STALL_o                                             (pcu_EX_MEM_STALL_o        ) ,
        .pcu_MEM_WB_FLUSH_o                                             (pcu_MEM_WB_FLUSH_o        ) ,
        .pcu_MEM_WB_STALL_o                                             (pcu_MEM_WB_STALL_o        )  
    );

    //  csrs
    assign      csr_pc_i                            =   MEM_WB_PC_o;
    assign      csr_instr_i                         =   MEM_WB_INSTR_o;
    assign      csr_bubble_flag_i                   =   MEM_WB_BUBBLE_FLAG_o;
    assign      csr_id_i                            =   idf_csr_id_o;
    assign      csr_write_back_en_i                 =   wbu_csr_write_back_en_o;
    assign      csr_write_back_id_i                 =   wbu_csr_write_back_id_o;
    assign      csr_write_back_data_i               =   wbu_csr_write_back_data_o;
    assign      csr_mei_flag_i                      =   wbu_mei_flag_o;
    assign      csr_msi_flag_i                      =   wbu_msi_flag_o;
    assign      csr_mti_flag_i                      =   wbu_mti_flag_o;
    assign      csr_irq_flag_i                      =   wbu_irq_flag_o;
    assign      csr_instr_addr_misalig_i            =   wbu_instr_addr_misalig_o;
    assign      csr_instr_acc_fault_i               =   wbu_instr_acc_fault_o   ;
    assign      csr_illegal_instr_i                 =   wbu_illegal_instr_o     ;
    assign      csr_ebreak_i                        =   wbu_ebreak_o            ;
    assign      csr_load_addr_misalig_i             =   wbu_load_addr_misalig_o ;
    assign      csr_load_acc_fault_i                =   wbu_load_acc_fault_o    ;
    assign      csr_store_addr_misalig_i            =   wbu_store_addr_misalig_o;
    assign      csr_store_acc_fault_i               =   wbu_store_acc_fault_o   ;
    assign      csr_ecall_i                         =   wbu_ecall_o             ;
    assign      csr_mret_i                          =   wbu_mret_flag_o              ;
    assign      csr_exc_flag_i                      =   wbu_exc_flag_o          ;
    csrs                                                                csrs
    (
        .clk                                                            (clk                 ) ,
        .rstn                                                            (rstn                 ) ,
        .instr                                                          (csr_instr_i                  ) , 
        .pc                                                             (csr_pc_i                  ) , 
        .bubble_flag                                                    (csr_bubble_flag_i         ) ,
        .csr_id                                                         (csr_id_i              ) , 
        .csr_write_back_en                                              (csr_write_back_en_i   ) ,
        .csr_write_back_id                                              (csr_write_back_id_i   ) , 
        .csr_write_back_data                                            (csr_write_back_data_i ) , 
        .mei_flag                                                       (csr_mei_flag_i            ) ,
        .msi_flag                                                       (csr_msi_flag_i            ) ,
        .mti_flag                                                       (csr_mti_flag_i            ) ,
        .irq_flag                                                       (csr_irq_flag_i            ) ,
        .instr_addr_misalig                                             (csr_instr_addr_misalig_i  ) ,
        .instr_acc_fault                                                (csr_instr_acc_fault_i     ) ,
        .illegal_instr                                                  (csr_illegal_instr_i       ) ,
        .ebreak                                                         (csr_ebreak_i              ) ,
        .load_addr_misalig                                              (csr_load_addr_misalig_i   ) ,
        .load_acc_fault                                                 (csr_load_acc_fault_i      ) ,
        .store_addr_misalig                                             (csr_store_addr_misalig_i  ) ,
        .store_acc_fault                                                (csr_store_acc_fault_i     ) ,
        .ecall                                                          (csr_ecall_i               ) ,
        .mret                                                           (csr_mret_i                ) ,
        .exc_flag                                                       (csr_exc_flag_i            ) ,
        .mstatus                                                        (csr_mstatus_o             ) , 
        .mie                                                            (csr_mie_o                 ) , 
        .mtvec                                                          (csr_mtvec_o               ) , 
        .mepc                                                           (csr_mepc_o                ) , 
        .csr_output                                                     (csr_output_o           )   
    );

    // ------------------------step1--------------------------
    assign      ifu_pc_hold_i                       =   pcu_PC_HOLD_o;
    assign      IFF_IFS_FLUSH_i                     =   pcu_IFF_IFS_FLUSH_o;
    assign      IFF_IFS_STALL_i                     =   pcu_IFF_IFS_STALL_o;
    assign      ifu_instr_i                         =   itcm_instr_o;
    assign      ifu_jalr_flag_i                     =   bpu_jalr_flag_o; 
    assign      ifu_jal_flag_i                      =   bpu_jal_flag_o; 
    assign      ifu_branch_flag_i                   =   bpu_branch_flag_o; 
    assign      ifu_jump_addr_i                     =   bpu_jump_addr_o; 
    assign      ifu_branch_predic_fault_i           =   exu_branch_predic_fault_o  ;
    assign      ifu_branch_reserve_addr_i           =   IDS_EX_BRANCH_RESERVE_ADDR_o;
    assign      ifu_exc_irq_flag_i                  =   wbu_exc_irq_flag_o         ;
    assign      ifu_exc_irq_srv_prog_addr_i         =   wbu_exc_irq_srv_prog_addr_o;
    assign      ifu_mret_i                          =   wbu_mret_flag_o  ;
    assign      ifu_mepc_i                          =   csr_mepc_o        ;
    ifu                                                                 ifu
    (
        .clk                                                            (clk                         ) ,
        .rstn                                                            (rstn                         ) ,
        .IFF_IFS_stall_i                                                (IFF_IFS_STALL_i             ) ,
        .IFF_IFS_flush_i                                                (IFF_IFS_FLUSH_i             ) ,
        .ifu_pc_hold_i                                                  (ifu_pc_hold_i               ) ,
        .ifu_jalr_flag_i                                                (ifu_jalr_flag_i           ) ,
        .ifu_jal_flag_i                                                 (ifu_jal_flag_i           ) ,
        .ifu_branch_flag_i                                              (ifu_branch_flag_i           ) ,
        .ifu_jump_addr_i                                                (ifu_jump_addr_i            ) , 
        .ifu_branch_predic_fault_i                                      (ifu_branch_predic_fault_i   ) ,
        .ifu_branch_reserve_addr_i                                      (ifu_branch_reserve_addr_i   ) , 
        .ifu_exc_irq_flag_i                                             (ifu_exc_irq_flag_i          ) ,
        .ifu_exc_irq_srv_prog_addr_i                                    (ifu_exc_irq_srv_prog_addr_i ) , 
        .ifu_mret_i                                                     (ifu_mret_i                  ) ,
        .ifu_mepc_i                                                     (ifu_mepc_i                  ) , 
        .ifu_fetch_addr_o                                               (ifu_fetch_addr_o              ) , 
        .ifu_instr_i                                                    (ifu_instr_i                 ) , 
        .ifu_bubble_flag_o                                              (ifu_bubble_flag_o           ) , 
        .ifu_instr_pc_o                                                 (ifu_instr_pc_o              ) , 
        .ifu_instr_o                                                    (ifu_instr_o                 )   

);
    //  itcm
    assign  itcm_pc_i     =   ifu_fetch_addr_o;
    itcm                                                                itcm
    (
        .clk                                                            (clk),
        .pc                                                             (itcm_pc_i),
        .instr                                                          (itcm_instr_o)
    );

    // ----------------------------IFS/IDF--------------------------
    assign      IFS_IDF_FLUSH_i                       =   pcu_IFS_IDF_FLUSH_o;
    assign      IFS_IDF_STALL_i                       =   pcu_IFS_IDF_STALL_o;
    assign      IFS_IDF_PC_i                          =   ifu_instr_pc_o;               
    assign      IFS_IDF_INSTR_i                       =   ifu_instr_o;            
    assign      IFS_IDF_BUBBLE_FLAG_i                 =   ifu_bubble_flag_o;
    assign      IFS_IDF_BRANCH_PREDIC_RES_i           =   bpu_branch_flag_o;
    assign      IFS_IDF_BRANCH_RESERVE_ADDR_i         =   bpu_branch_reserve_addr_o;
    IFS_IDF                                                             IFS_IDF
    (
        .clk                                                            (clk),
        .rstn                                                            (rstn),
        .flush                                                          (IFS_IDF_FLUSH_i),
        .stall                                                          (IFS_IDF_STALL_i),
        .IFS_IDF_PC_i                                                   (IFS_IDF_PC_i),
        .IFS_IDF_INSTR_i                                                (IFS_IDF_INSTR_i),
        .IFS_IDF_BUBBLE_FLAG_i                                          (IFS_IDF_BUBBLE_FLAG_i),
        .IFS_IDF_BRANCH_RESERVE_ADDR_i                                  (IFS_IDF_BRANCH_RESERVE_ADDR_i),
        .IFS_IDF_BRANCH_PREDIC_RES_i                                    (IFS_IDF_BRANCH_PREDIC_RES_i),
        .IFS_IDF_PC_o                                                   (IFS_IDF_PC_o),
        .IFS_IDF_INSTR_o                                                (IFS_IDF_INSTR_o),
        .IFS_IDF_BUBBLE_FLAG_o                                          (IFS_IDF_BUBBLE_FLAG_o),
        .IFS_IDF_BRANCH_RESERVE_ADDR_o                                  (IFS_IDF_BRANCH_RESERVE_ADDR_o),
        .IFS_IDF_BRANCH_PREDIC_RES_o                                    (IFS_IDF_BRANCH_PREDIC_RES_o)
    );
    //----------------------------------IDF---------------------------------------------------
    assign      idf_instr_i                     =   IFS_IDF_INSTR_o;
    assign      idf_gpr_ids_rd_i                =   IDF_IDS_GPR_WRITE_BACK_ID_o;
    assign      idf_gpr_ex_rd_i                 =   IDS_EX_GPR_WRITE_BACK_ID_o & {5{!(IDS_EX_INSTR_LOAD_o | IDS_EX_INSTR_STORE_o)}};
    assign      idf_gpr_mem_rd_i                =   EX_MEM_GPR_WRITE_BACK_ID_o;
    assign      idf_gpr_wb_rd_i                 =   MEM_WB_GPR_WRITE_BACK_ID_o;
    assign      idf_csr_ids_rd_i                =   {12{IDF_IDS_CSR_WRITE_BACK_EN_o}}   & IDF_IDS_CSR_WRITE_BACK_ID_o;
    assign      idf_csr_ex_rd_i                 =   {12{IDS_EX_CSR_WRITE_BACK_EN_o}}    & IDS_EX_CSR_WRITE_BACK_ID_o;
    assign      idf_csr_mem_rd_i                =   {12{EX_MEM_CSR_WRITE_BACK_EN_o}}    & EX_MEM_CSR_WRITE_BACK_ID_o;
    assign      idf_csr_wb_rd_i                 =   {12{MEM_WB_CSR_WRITE_BACK_EN_o}}    & MEM_WB_CSR_WRITE_BACK_ID_o;
    assign      idf_gpr_write_back_en_i         =   wbu_gpr_write_back_en_o;
    assign      idf_gpr_write_back_id_i         =   wbu_gpr_write_back_id_o;
    assign      idf_gpr_write_back_data_i       =   wbu_gpr_write_back_data_o;

    idf                                                                 idf
    (
        .clk                                                            (clk                   ) ,
        .idf_instr_i                                                    (idf_instr_i                   ) ,
        .idf_gpr_ids_rd_i                                               (idf_gpr_ids_rd_i               ) , 
        .idf_gpr_ex_rd_i                                                (idf_gpr_ex_rd_i               ) , 
        .idf_gpr_mem_rd_i                                               (idf_gpr_mem_rd_i              ) , 
        .idf_gpr_wb_rd_i                                                (idf_gpr_wb_rd_i               ) , 
        .idf_csr_ids_rd_i                                               (idf_csr_ids_rd_i               ) , 
        .idf_csr_ex_rd_i                                                (idf_csr_ex_rd_i               ) , 
        .idf_csr_mem_rd_i                                               (idf_csr_mem_rd_i              ) , 
        .idf_csr_wb_rd_i                                                (idf_csr_wb_rd_i               ) , 
        .idf_gpr_write_back_en_i                                        (idf_gpr_write_back_en_i       ) ,
        .idf_gpr_write_back_id_i                                        (idf_gpr_write_back_id_i       ) , 
        .idf_gpr_write_back_data_i                                      (idf_gpr_write_back_data_i     ) , 
        .idf_instr_load_o                                               (idf_instr_load_o              ) ,
        .idf_instr_load_fp_o                                            (idf_instr_load_fp_o           ) ,
        .idf_instr_misc_mem_o                                           (idf_instr_misc_mem_o          ) ,
        .idf_instr_op_imm_o                                             (idf_instr_op_imm_o            ) ,
        .idf_instr_auipc_o                                              (idf_instr_auipc_o             ) ,
        .idf_instr_op_imm_32_o                                          (idf_instr_op_imm_32_o         ) ,
        .idf_instr_store_o                                              (idf_instr_store_o             ) ,
        .idf_instr_store_fp_o                                           (idf_instr_store_fp_o          ) ,
        .idf_instr_amo_o                                                (idf_instr_amo_o               ) ,
        .idf_instr_op_o                                                 (idf_instr_op_o                ) ,
        .idf_instr_lui_o                                                (idf_instr_lui_o               ) ,
        .idf_instr_op_32_o                                              (idf_instr_op_32_o             ) ,
        .idf_instr_madd_o                                               (idf_instr_madd_o              ) ,
        .idf_instr_msub_o                                               (idf_instr_msub_o              ) ,
        .idf_instr_nmsub_o                                              (idf_instr_nmsub_o             ) ,
        .idf_instr_nmadd_o                                              (idf_instr_nmadd_o             ) ,
        .idf_instr_op_fp_o                                              (idf_instr_op_fp_o             ) ,
        .idf_instr_branch_o                                             (idf_instr_branch_o            ) ,
        .idf_instr_jalr_o                                               (idf_instr_jalr_o              ) ,
        .idf_instr_jal_o                                                (idf_instr_jal_o               ) ,
        .idf_instr_system_o                                             (idf_instr_system_o            ) ,
        .idf_funct3_o                                                   (idf_funct3_o                  ) , 
        .idf_funct7_o                                                   (idf_funct7_o                  ) , 
        .idf_funct5_o                                                   (idf_funct5_o                  ) , 
        .idf_funct12_o                                                  (idf_funct12_o                 ) , 
        .idf_alu_op_o                                                   (idf_alu_op_o                  ) , 
        .idf_mdu_op_o                                                   (idf_mdu_op_o                  ) , 
        .idf_alu_shift_mode_o                                           (idf_alu_shift_mode_o          ) , 
        .idf_disp_target_o                                              (idf_disp_target_o             ) ,  
        .idf_operand1_sel_o                                             (idf_operand1_sel_o            ) ,
        .idf_operand2_sel_o                                             (idf_operand2_sel_o            ) ,
        .idf_rs1_bypassdata_sel_o                                       (idf_rs1_bypassdata_sel_o   ) ,
        .idf_rs2_bypassdata_sel_o                                       (idf_rs2_bypassdata_sel_o   ) ,
        .idf_csr_bypassdata_sel_o                                       (idf_csr_bypassdata_sel_o   ) ,
        .idf_rs1_bypassdata_ex_sel_o                                    (idf_rs1_bypassdata_ex_sel_o   ) ,
        .idf_rs1_bypassdata_mem_sel_o                                   (idf_rs1_bypassdata_mem_sel_o  ) ,
        .idf_rs1_bypassdata_wb_sel_o                                    (idf_rs1_bypassdata_wb_sel_o   ) ,
        .idf_rs2_bypassdata_ex_sel_o                                    (idf_rs2_bypassdata_ex_sel_o   ) ,
        .idf_rs2_bypassdata_mem_sel_o                                   (idf_rs2_bypassdata_mem_sel_o  ) ,
        .idf_rs2_bypassdata_wb_sel_o                                    (idf_rs2_bypassdata_wb_sel_o   ) ,
        .idf_csr_bypassdata_ex_sel_o                                    (idf_csr_bypassdata_ex_sel_o   ) ,
        .idf_csr_bypassdata_mem_sel_o                                   (idf_csr_bypassdata_mem_sel_o  ) ,
        .idf_csr_bypassdata_wb_sel_o                                    (idf_csr_bypassdata_wb_sel_o   ) ,
        .idf_data_raw_depcy_o                                           (idf_data_raw_depcy_o   ) ,
        .idf_gpr_write_back_en_o                                        (idf_gpr_write_back_en_o       ) ,
        .idf_gpr_write_back_id_o                                        (idf_gpr_write_back_id_o       ) , 
        .idf_gpr_write_back_from_alu_o                                  (idf_gpr_write_back_from_alu_o ) ,
        .idf_gpr_write_back_from_lsu_o                                  (idf_gpr_write_back_from_lsu_o ) ,
        .idf_gpr_write_back_from_mdu_o                                  (idf_gpr_write_back_from_mdu_o ) ,
        .idf_csr_id_o                                                   (idf_csr_id_o                  ) , 
        .idf_csr_write_back_en_o                                        (idf_csr_write_back_en_o       ) ,
        .idf_csr_write_back_id_o                                        (idf_csr_write_back_id_o       ) , 
        .idf_imm_o                                                      (idf_imm_o                     ) , 
        .idf_jalr_offset_o                                              (idf_jalr_offset_o             ) , 
        .idf_illegal_instr_flag_o                                       (idf_illegal_instr_flag_o      ) ,
        .idf_gpr_output1_o                                              (idf_gpr_output1_o             ) , 
        .idf_gpr_output2_o                                              (idf_gpr_output2_o             ) 
    );
    //  ------------------------------------------IDF/IDS-------------------------------
    assign      IDF_IDS_FLUSH_i                                     =   pcu_IDF_IDS_FLUSH_o;
    assign      IDF_IDS_STALL_i                                     =   pcu_IDF_IDS_STALL_o;
    assign      IDF_IDS_BUBBLE_FLAG_i                               =   IFS_IDF_BUBBLE_FLAG_o;
    assign      IDF_IDS_ILLEGAL_INSTR_FLAG_i                        =   idf_illegal_instr_flag_o;
    assign      IDF_IDS_PC_i                                        =   IFS_IDF_PC_o;
    assign      IDF_IDS_INSTR_i                                     =   IFS_IDF_INSTR_o;
    assign      IDF_IDS_FUNCT3_i                                    =   idf_funct3_o;
    assign      IDF_IDS_INSTR_JALR_i                                =   idf_instr_jalr_o;
    assign      IDF_IDS_INSTR_LOAD_i                                =   idf_instr_load_o;
    assign      IDF_IDS_INSTR_STORE_i                               =   idf_instr_store_o;
    assign      IDF_IDS_INSTR_SYSTEM_i                              =   idf_instr_system_o;
    assign      IDF_IDS_INSTR_BRANCH_i                              =   idf_instr_branch_o;
    assign      IDF_IDS_BRANCH_PREDIC_RES_i                         =   IFS_IDF_BRANCH_PREDIC_RES_o;
    assign      IDF_IDS_BRANCH_RESERVE_ADDR_i                       =   IFS_IDF_BRANCH_RESERVE_ADDR_o;
    assign      IDF_IDS_OPERAND1_SEL_i                              =   idf_operand1_sel_o;
    assign      IDF_IDS_OPERAND2_SEL_i                              =   idf_operand2_sel_o;
    assign      IDF_IDS_CSR_OUTPUT_i                                =   csr_output_o;
    assign      IDF_IDS_GPR_OUTPUT1_i                               =   idf_gpr_output1_o;
    assign      IDF_IDS_GPR_OUTPUT2_i                               =   idf_gpr_output2_o;
    assign      IDF_IDS_IMM_i                                       =   idf_imm_o;
    assign      IDF_IDS_GPR_BYPASSDATA_EX_i                         =   exu_alu_output_o;
    assign      IDF_IDS_GPR_BYPASSDATA_MEM_i                        =   (EX_MEM_INSTR_LOAD_o | EX_MEM_INSTR_STORE_o) ? lsu_load_data_o : EX_MEM_ALU_OUTPUT_o;
    assign      IDF_IDS_GPR_BYPASSDATA_WB_i                         =   wbu_gpr_write_back_data_o;
    assign      IDF_IDS_CSR_BYPASSDATA_EX_i                         =   exu_csr_write_back_data_o;
    assign      IDF_IDS_CSR_BYPASSDATA_MEM_i                        =   EX_MEM_CSR_WRITE_BACK_DATA_o;
    assign      IDF_IDS_CSR_BYPASSDATA_WB_i                         =   wbu_csr_write_back_data_o;
    //
    assign      IDF_IDS_RS1_BYPASSDATA_SEL_i                        =   idf_rs1_bypassdata_sel_o;
    assign      IDF_IDS_RS2_BYPASSDATA_SEL_i                        =   idf_rs2_bypassdata_sel_o;
    assign      IDF_IDS_CSR_BYPASSDATA_SEL_i                        =   idf_csr_bypassdata_sel_o;
    assign      IDF_IDS_RS1_BYPASSDATA_EX_SEL_i                     =   idf_rs1_bypassdata_ex_sel_o ;
    assign      IDF_IDS_RS1_BYPASSDATA_MEM_SEL_i                    =   idf_rs1_bypassdata_mem_sel_o;
    assign      IDF_IDS_RS1_BYPASSDATA_WB_SEL_i                     =   idf_rs1_bypassdata_wb_sel_o ;
    assign      IDF_IDS_RS2_BYPASSDATA_EX_SEL_i                     =   idf_rs2_bypassdata_ex_sel_o ;
    assign      IDF_IDS_RS2_BYPASSDATA_MEM_SEL_i                    =   idf_rs2_bypassdata_mem_sel_o;
    assign      IDF_IDS_RS2_BYPASSDATA_WB_SEL_i                     =   idf_rs2_bypassdata_wb_sel_o ;
    assign      IDF_IDS_CSR_BYPASSDATA_EX_SEL_i                     =   idf_csr_bypassdata_ex_sel_o ;
    assign      IDF_IDS_CSR_BYPASSDATA_MEM_SEL_i                    =   idf_csr_bypassdata_mem_sel_o;
    assign      IDF_IDS_CSR_BYPASSDATA_WB_SEL_i                     =   idf_csr_bypassdata_wb_sel_o ;
    assign      IDF_IDS_GPR_WRITE_BACK_EN_i                         =   idf_gpr_write_back_en_o;
    assign      IDF_IDS_GPR_WRITE_BACK_ID_i                         =   idf_gpr_write_back_id_o;
    assign      IDF_IDS_GPR_WRITE_BACK_FROM_ALU_i                   =   idf_gpr_write_back_from_alu_o;
    assign      IDF_IDS_GPR_WRITE_BACK_FROM_LSU_i                   =   idf_gpr_write_back_from_lsu_o;
    assign      IDF_IDS_GPR_WRITE_BACK_FROM_MDU_i                   =   idf_gpr_write_back_from_mdu_o;
    assign      IDF_IDS_DISP_TARGET_i                               =   idf_disp_target_o;
    assign      IDF_IDS_CSR_WRITE_BACK_EN_i                         =   idf_csr_write_back_en_o;
    assign      IDF_IDS_CSR_WRITE_BACK_ID_i                         =   idf_csr_write_back_id_o;
    assign      IDF_IDS_ALU_SHIFT_MODE_i                            =   idf_alu_shift_mode_o;
    assign      IDF_IDS_ALU_OP_i                                    =   idf_alu_op_o;
    assign      IDF_IDS_MDU_OP_i                                    =   idf_mdu_op_o;
    assign      IDF_IDS_JALR_OFFSET_i                               =   idf_jalr_offset_o;

    IDF_IDS                                                             IDF_IDS
    (
        .clk                                                            (clk                               ) ,
        .rstn                                                            (rstn                               ) ,
        .flush                                                          (IDF_IDS_FLUSH_i                  ) ,
        .stall                                                          (IDF_IDS_STALL_i                   ) ,
        .IDF_IDS_BUBBLE_FLAG_i                                          (IDF_IDS_BUBBLE_FLAG_i             ) ,
        .IDF_IDS_ILLEGAL_INSTR_FLAG_i                                   (IDF_IDS_ILLEGAL_INSTR_FLAG_i      ) ,
        .IDF_IDS_PC_i                                                   (IDF_IDS_PC_i                      ) , 
        .IDF_IDS_INSTR_i                                                (IDF_IDS_INSTR_i                   ) , 
        .IDF_IDS_FUNCT3_i                                               (IDF_IDS_FUNCT3_i                  ) ,
        .IDF_IDS_INSTR_JALR_i                                           (IDF_IDS_INSTR_JALR_i              ) , 
        .IDF_IDS_INSTR_LOAD_i                                           (IDF_IDS_INSTR_LOAD_i              ) ,
        .IDF_IDS_INSTR_STORE_i                                          (IDF_IDS_INSTR_STORE_i             ) ,
        .IDF_IDS_INSTR_SYSTEM_i                                         (IDF_IDS_INSTR_SYSTEM_i            ) ,
        .IDF_IDS_INSTR_BRANCH_i                                         (IDF_IDS_INSTR_BRANCH_i            ) ,
        .IDF_IDS_BRANCH_PREDIC_RES_i                                    (IDF_IDS_BRANCH_PREDIC_RES_i       ) ,
        .IDF_IDS_BRANCH_RESERVE_ADDR_i                                  (IDF_IDS_BRANCH_RESERVE_ADDR_i     ) , 
        .IDF_IDS_OPERAND1_SEL_i                                         (IDF_IDS_OPERAND1_SEL_i            ) ,
        .IDF_IDS_OPERAND2_SEL_i                                         (IDF_IDS_OPERAND2_SEL_i            ) ,
        .IDF_IDS_CSR_OUTPUT_i                                           (IDF_IDS_CSR_OUTPUT_i),
        .IDF_IDS_GPR_OUTPUT1_i                                          (IDF_IDS_GPR_OUTPUT1_i             ) , 
        .IDF_IDS_GPR_OUTPUT2_i                                          (IDF_IDS_GPR_OUTPUT2_i             ) , 
        .IDF_IDS_IMM_i                                                  (IDF_IDS_IMM_i                     ) , 
        .IDF_IDS_GPR_BYPASSDATA_EX_i                                    (IDF_IDS_GPR_BYPASSDATA_EX_i       ) , 
        .IDF_IDS_GPR_BYPASSDATA_MEM_i                                   (IDF_IDS_GPR_BYPASSDATA_MEM_i      ) , 
        .IDF_IDS_GPR_BYPASSDATA_WB_i                                    (IDF_IDS_GPR_BYPASSDATA_WB_i       ) , 
        .IDF_IDS_CSR_BYPASSDATA_EX_i                                    (IDF_IDS_CSR_BYPASSDATA_EX_i       ) , 
        .IDF_IDS_CSR_BYPASSDATA_MEM_i                                   (IDF_IDS_CSR_BYPASSDATA_MEM_i      ) , 
        .IDF_IDS_CSR_BYPASSDATA_WB_i                                    (IDF_IDS_CSR_BYPASSDATA_WB_i       ) ,
        .IDF_IDS_RS1_BYPASSDATA_SEL_i                                   (IDF_IDS_RS1_BYPASSDATA_SEL_i),
        .IDF_IDS_RS2_BYPASSDATA_SEL_i                                   (IDF_IDS_RS2_BYPASSDATA_SEL_i),
        .IDF_IDS_CSR_BYPASSDATA_SEL_i                                   (IDF_IDS_CSR_BYPASSDATA_SEL_i),
        .IDF_IDS_RS1_BYPASSDATA_EX_SEL_i                                (IDF_IDS_RS1_BYPASSDATA_EX_SEL_i ),
        .IDF_IDS_RS1_BYPASSDATA_MEM_SEL_i                               (IDF_IDS_RS1_BYPASSDATA_MEM_SEL_i),
        .IDF_IDS_RS1_BYPASSDATA_WB_SEL_i                                (IDF_IDS_RS1_BYPASSDATA_WB_SEL_i ),
        .IDF_IDS_RS2_BYPASSDATA_EX_SEL_i                                (IDF_IDS_RS2_BYPASSDATA_EX_SEL_i ),
        .IDF_IDS_RS2_BYPASSDATA_MEM_SEL_i                               (IDF_IDS_RS2_BYPASSDATA_MEM_SEL_i),
        .IDF_IDS_RS2_BYPASSDATA_WB_SEL_i                                (IDF_IDS_RS2_BYPASSDATA_WB_SEL_i ),
        .IDF_IDS_CSR_BYPASSDATA_EX_SEL_i                                (IDF_IDS_CSR_BYPASSDATA_EX_SEL_i ),
        .IDF_IDS_CSR_BYPASSDATA_MEM_SEL_i                               (IDF_IDS_CSR_BYPASSDATA_MEM_SEL_i),
        .IDF_IDS_CSR_BYPASSDATA_WB_SEL_i                                (IDF_IDS_CSR_BYPASSDATA_WB_SEL_i ),

        .IDF_IDS_GPR_WRITE_BACK_EN_i                                    (IDF_IDS_GPR_WRITE_BACK_EN_i       ) ,
        .IDF_IDS_GPR_WRITE_BACK_ID_i                                    (IDF_IDS_GPR_WRITE_BACK_ID_i       ) , 
        .IDF_IDS_GPR_WRITE_BACK_FROM_ALU_i                              (IDF_IDS_GPR_WRITE_BACK_FROM_ALU_i ) ,
        .IDF_IDS_GPR_WRITE_BACK_FROM_LSU_i                              (IDF_IDS_GPR_WRITE_BACK_FROM_LSU_i ) ,
        .IDF_IDS_GPR_WRITE_BACK_FROM_MDU_i                              (IDF_IDS_GPR_WRITE_BACK_FROM_MDU_i ) ,
        .IDF_IDS_DISP_TARGET_i                                          (IDF_IDS_DISP_TARGET_i             ) , 
        .IDF_IDS_CSR_WRITE_BACK_EN_i                                    (IDF_IDS_CSR_WRITE_BACK_EN_i       ) ,
        .IDF_IDS_CSR_WRITE_BACK_ID_i                                    (IDF_IDS_CSR_WRITE_BACK_ID_i       ) , 
        .IDF_IDS_ALU_SHIFT_MODE_i                                       (IDF_IDS_ALU_SHIFT_MODE_i          ) , 
        .IDF_IDS_ALU_OP_i                                               (IDF_IDS_ALU_OP_i                  ) , 
        .IDF_IDS_MDU_OP_i                                               (IDF_IDS_MDU_OP_i                  ) , 
        .IDF_IDS_JALR_OFFSET_i                                          (IDF_IDS_JALR_OFFSET_i             ) , 
        .IDF_IDS_BUBBLE_FLAG_o                                          (IDF_IDS_BUBBLE_FLAG_o             ) ,
        .IDF_IDS_ILLEGAL_INSTR_FLAG_o                                   (IDF_IDS_ILLEGAL_INSTR_FLAG_o      ) ,
        .IDF_IDS_PC_o                                                   (IDF_IDS_PC_o                      ) , 
        .IDF_IDS_FUNCT3_o                                               (IDF_IDS_FUNCT3_o                  ) , 
        .IDF_IDS_INSTR_o                                                (IDF_IDS_INSTR_o                   ) , 
        .IDF_IDS_INSTR_JALR_o                                           (IDF_IDS_INSTR_JALR_o              ) ,
        .IDF_IDS_INSTR_LOAD_o                                           (IDF_IDS_INSTR_LOAD_o              ) ,
        .IDF_IDS_INSTR_STORE_o                                          (IDF_IDS_INSTR_STORE_o             ) ,
        .IDF_IDS_INSTR_SYSTEM_o                                         (IDF_IDS_INSTR_SYSTEM_o            ) ,
        .IDF_IDS_INSTR_BRANCH_o                                         (IDF_IDS_INSTR_BRANCH_o            ) ,
        .IDF_IDS_BRANCH_PREDIC_RES_o                                    (IDF_IDS_BRANCH_PREDIC_RES_o       ) ,
        .IDF_IDS_BRANCH_RESERVE_ADDR_o                                  (IDF_IDS_BRANCH_RESERVE_ADDR_o     ) , 
        .IDF_IDS_OPERAND1_SEL_o                                         (IDF_IDS_OPERAND1_SEL_o            ) ,
        .IDF_IDS_OPERAND2_SEL_o                                         (IDF_IDS_OPERAND2_SEL_o            ) ,
        .IDF_IDS_CSR_OUTPUT_o                                           (IDF_IDS_CSR_OUTPUT_o),
        .IDF_IDS_GPR_OUTPUT1_o                                          (IDF_IDS_GPR_OUTPUT1_o             ) , 
        .IDF_IDS_GPR_OUTPUT2_o                                          (IDF_IDS_GPR_OUTPUT2_o             ) , 
        .IDF_IDS_IMM_o                                                  (IDF_IDS_IMM_o                     ) , 
        .IDF_IDS_GPR_BYPASSDATA_EX_o                                    (IDF_IDS_GPR_BYPASSDATA_EX_o       ) , 
        .IDF_IDS_GPR_BYPASSDATA_MEM_o                                   (IDF_IDS_GPR_BYPASSDATA_MEM_o      ) , 
        .IDF_IDS_GPR_BYPASSDATA_WB_o                                    (IDF_IDS_GPR_BYPASSDATA_WB_o       ) , 
        .IDF_IDS_CSR_BYPASSDATA_EX_o                                    (IDF_IDS_CSR_BYPASSDATA_EX_o       ) , 
        .IDF_IDS_CSR_BYPASSDATA_MEM_o                                   (IDF_IDS_CSR_BYPASSDATA_MEM_o      ) , 
        .IDF_IDS_CSR_BYPASSDATA_WB_o                                    (IDF_IDS_CSR_BYPASSDATA_WB_o       ) ,
        .IDF_IDS_RS1_BYPASSDATA_SEL_o                                   (IDF_IDS_RS1_BYPASSDATA_SEL_o),
        .IDF_IDS_RS2_BYPASSDATA_SEL_o                                   (IDF_IDS_RS2_BYPASSDATA_SEL_o),
        .IDF_IDS_CSR_BYPASSDATA_SEL_o                                   (IDF_IDS_CSR_BYPASSDATA_SEL_o),
        .IDF_IDS_RS1_BYPASSDATA_EX_SEL_o                                (IDF_IDS_RS1_BYPASSDATA_EX_SEL_o ),
        .IDF_IDS_RS1_BYPASSDATA_MEM_SEL_o                               (IDF_IDS_RS1_BYPASSDATA_MEM_SEL_o),
        .IDF_IDS_RS1_BYPASSDATA_WB_SEL_o                                (IDF_IDS_RS1_BYPASSDATA_WB_SEL_o ),
        .IDF_IDS_RS2_BYPASSDATA_EX_SEL_o                                (IDF_IDS_RS2_BYPASSDATA_EX_SEL_o ),
        .IDF_IDS_RS2_BYPASSDATA_MEM_SEL_o                               (IDF_IDS_RS2_BYPASSDATA_MEM_SEL_o),
        .IDF_IDS_RS2_BYPASSDATA_WB_SEL_o                                (IDF_IDS_RS2_BYPASSDATA_WB_SEL_o ),
        .IDF_IDS_CSR_BYPASSDATA_EX_SEL_o                                (IDF_IDS_CSR_BYPASSDATA_EX_SEL_o ),
        .IDF_IDS_CSR_BYPASSDATA_MEM_SEL_o                               (IDF_IDS_CSR_BYPASSDATA_MEM_SEL_o),
        .IDF_IDS_CSR_BYPASSDATA_WB_SEL_o                                (IDF_IDS_CSR_BYPASSDATA_WB_SEL_o ), 
        .IDF_IDS_GPR_WRITE_BACK_EN_o                                    (IDF_IDS_GPR_WRITE_BACK_EN_o       ) ,
        .IDF_IDS_GPR_WRITE_BACK_ID_o                                    (IDF_IDS_GPR_WRITE_BACK_ID_o       ) , 
        .IDF_IDS_GPR_WRITE_BACK_FROM_ALU_o                              (IDF_IDS_GPR_WRITE_BACK_FROM_ALU_o ) ,
        .IDF_IDS_GPR_WRITE_BACK_FROM_LSU_o                              (IDF_IDS_GPR_WRITE_BACK_FROM_LSU_o ) ,
        .IDF_IDS_GPR_WRITE_BACK_FROM_MDU_o                              (IDF_IDS_GPR_WRITE_BACK_FROM_MDU_o ) ,
        .IDF_IDS_CSR_WRITE_BACK_EN_o                                    (IDF_IDS_CSR_WRITE_BACK_EN_o       ) ,
        .IDF_IDS_CSR_WRITE_BACK_ID_o                                    (IDF_IDS_CSR_WRITE_BACK_ID_o       ) , 
        .IDF_IDS_DISP_TARGET_o                                          (IDF_IDS_DISP_TARGET_o             ) , 
        .IDF_IDS_ALU_SHIFT_MODE_o                                       (IDF_IDS_ALU_SHIFT_MODE_o          ) , 
        .IDF_IDS_ALU_OP_o                                               (IDF_IDS_ALU_OP_o                  ) , 
        .IDF_IDS_MDU_OP_o                                               (IDF_IDS_MDU_OP_o                  ) , 
        .IDF_IDS_JALR_OFFSET_o                                          (IDF_IDS_JALR_OFFSET_o             )
    );
    //----------------------------IDS------------------------------------
    assign      ids_alu_shift_mode_i                        =   IDF_IDS_ALU_SHIFT_MODE_o;
    assign      ids_alu_op_i                                =   IDF_IDS_ALU_OP_o;
    assign      ids_pc_i                                    =   IDF_IDS_PC_o;
    assign      ids_imm_i                                   =   IDF_IDS_IMM_o;
    assign      ids_operand1_sel_i                          =   IDF_IDS_OPERAND1_SEL_o;
    assign      ids_operand2_sel_i                          =   IDF_IDS_OPERAND2_SEL_o;
    assign      ids_rs1_bypassdata_sel_i                    =   IDF_IDS_RS1_BYPASSDATA_SEL_o;
    assign      ids_rs2_bypassdata_sel_i                    =   IDF_IDS_RS2_BYPASSDATA_SEL_o;
    assign      ids_csr_bypassdata_sel_i                    =   IDF_IDS_CSR_BYPASSDATA_SEL_o;
    assign      ids_rs1_bypassdata_ex_sel_i                 =   IDF_IDS_RS1_BYPASSDATA_EX_SEL_o ;
    assign      ids_rs1_bypassdata_mem_sel_i                =   IDF_IDS_RS1_BYPASSDATA_MEM_SEL_o;
    assign      ids_rs1_bypassdata_wb_sel_i                 =   IDF_IDS_RS1_BYPASSDATA_WB_SEL_o ;
    assign      ids_rs2_bypassdata_ex_sel_i                 =   IDF_IDS_RS2_BYPASSDATA_EX_SEL_o ;
    assign      ids_rs2_bypassdata_mem_sel_i                =   IDF_IDS_RS2_BYPASSDATA_MEM_SEL_o;
    assign      ids_rs2_bypassdata_wb_sel_i                 =   IDF_IDS_RS2_BYPASSDATA_WB_SEL_o ;
    assign      ids_csr_bypassdata_ex_sel_i                 =   IDF_IDS_CSR_BYPASSDATA_EX_SEL_o ;
    assign      ids_csr_bypassdata_mem_sel_i                =   IDF_IDS_CSR_BYPASSDATA_MEM_SEL_o;
    assign      ids_csr_bypassdata_wb_sel_i                 =   IDF_IDS_CSR_BYPASSDATA_WB_SEL_o ;
    //
    assign      ids_gpr_bypassdata_ex_i                     =   IDF_IDS_GPR_BYPASSDATA_EX_o; 
    assign      ids_gpr_bypassdata_mem_i                    =   IDF_IDS_GPR_BYPASSDATA_MEM_o; 
    assign      ids_gpr_bypassdata_wb_i                     =   IDF_IDS_GPR_BYPASSDATA_WB_o; 
    assign      ids_csr_bypassdata_ex_i                     =   IDF_IDS_CSR_BYPASSDATA_EX_o; 
    assign      ids_csr_bypassdata_mem_i                    =   IDF_IDS_CSR_BYPASSDATA_MEM_o; 
    assign      ids_csr_bypassdata_wb_i                     =   IDF_IDS_CSR_BYPASSDATA_WB_o;
    assign      ids_csr_output_i                            =   IDF_IDS_CSR_OUTPUT_o;
    assign      ids_gpr_output1_i                           =   IDF_IDS_GPR_OUTPUT1_o;
    assign      ids_gpr_output2_i                           =   IDF_IDS_GPR_OUTPUT2_o;
    ids                                                                 ids
    (
        .ids_alu_shift_mode_i                                           (ids_alu_shift_mode_i),
        .ids_alu_op_i                                                   (ids_alu_op_i),
        .ids_pc_i                                                       (ids_pc_i                     ) , 
        .ids_imm_i                                                      (ids_imm_i                    ) , 
        .ids_operand1_sel_i                                             (ids_operand1_sel_i           ) ,
        .ids_operand2_sel_i                                             (ids_operand2_sel_i           ) ,
        .ids_rs1_bypassdata_sel_i                                       (ids_rs1_bypassdata_sel_i),
        .ids_rs2_bypassdata_sel_i                                       (ids_rs2_bypassdata_sel_i),
        .ids_csr_bypassdata_sel_i                                       (ids_csr_bypassdata_sel_i),
        .ids_rs1_bypassdata_ex_sel_i                                    (ids_rs1_bypassdata_ex_sel_i  ) ,
        .ids_rs1_bypassdata_mem_sel_i                                   (ids_rs1_bypassdata_mem_sel_i ) ,
        .ids_rs1_bypassdata_wb_sel_i                                    (ids_rs1_bypassdata_wb_sel_i  ) ,
        .ids_rs2_bypassdata_ex_sel_i                                    (ids_rs2_bypassdata_ex_sel_i  ) ,
        .ids_rs2_bypassdata_mem_sel_i                                   (ids_rs2_bypassdata_mem_sel_i ) ,
        .ids_rs2_bypassdata_wb_sel_i                                    (ids_rs2_bypassdata_wb_sel_i  ) ,
        .ids_csr_bypassdata_ex_sel_i                                    (ids_csr_bypassdata_ex_sel_i  ) ,
        .ids_csr_bypassdata_mem_sel_i                                   (ids_csr_bypassdata_mem_sel_i ) ,
        .ids_csr_bypassdata_wb_sel_i                                    (ids_csr_bypassdata_wb_sel_i  ) ,
        .ids_csr_output_i                                               (ids_csr_output_i             ) , 
        .ids_gpr_output1_i                                              (ids_gpr_output1_i            ) , 
        .ids_gpr_output2_i                                              (ids_gpr_output2_i            ) , 
        .ids_gpr_bypassdata_ex_i                                        (ids_gpr_bypassdata_ex_i      ) , 
        .ids_gpr_bypassdata_mem_i                                       (ids_gpr_bypassdata_mem_i     ) , 
        .ids_gpr_bypassdata_wb_i                                        (ids_gpr_bypassdata_wb_i      ) , 
        .ids_csr_bypassdata_ex_i                                        (ids_csr_bypassdata_ex_i      ) , 
        .ids_csr_bypassdata_mem_i                                       (ids_csr_bypassdata_mem_i     ) , 
        .ids_csr_bypassdata_wb_i                                        (ids_csr_bypassdata_wb_i      ) , 
        .ids_operand1_o                                                 (ids_operand1_o               ) ,
        .ids_operand2_o                                                 (ids_operand2_o               ) ,
        .ids_rs1_data_o                                                 (ids_rs1_data_o               ) , 
        .ids_rs2_data_o                                                 (ids_rs2_data_o               ) ,
        .ids_csr_data_o                                                 (ids_csr_data_o               ) ,
        .ids_shift2_o                                                   (ids_shift2_o),
        .ids_add_res_l_o                                                (ids_add_res_l_o ),
        .ids_add_res_h_o                                                (ids_add_res_h_o ),
        .ids_sub_res_l_o                                                (ids_sub_res_l_o ),
        .ids_sub_res_h_o                                                (ids_sub_res_h_o ),
        .ids_subu_res_l_o                                               (ids_subu_res_l_o),
        .ids_subu_res_h_o                                               (ids_subu_res_h_o)
    );
    //-------------------------------------------IDS_EX-------------------------------------
    assign      IDS_EX_FLUSH_i                              =   pcu_IDS_EX_FLUSH_o;
    assign      IDS_EX_STALL_i                              =   pcu_IDS_EX_STALL_o;
    assign      IDS_EX_BUBBLE_FLAG_i                        =   IDF_IDS_BUBBLE_FLAG_o;
    assign      IDS_EX_ILLEGAL_INSTR_FLAG_i                 =   IDF_IDS_ILLEGAL_INSTR_FLAG_o;
    assign      IDS_EX_PC_i                                 =   IDF_IDS_PC_o;
    assign      IDS_EX_INSTR_i                              =   IDF_IDS_INSTR_o;
    assign      IDS_EX_FUNCT3_i                             =   IDF_IDS_FUNCT3_o;
    assign      IDS_EX_INSTR_JALR_i                         =   IDF_IDS_INSTR_JALR_o;
    assign      IDS_EX_INSTR_LOAD_i                         =   IDF_IDS_INSTR_LOAD_o;
    assign      IDS_EX_INSTR_STORE_i                        =   IDF_IDS_INSTR_STORE_o;
    assign      IDS_EX_INSTR_SYSTEM_i                       =   IDF_IDS_INSTR_SYSTEM_o;
    assign      IDS_EX_INSTR_BRANCH_i                       =   IDF_IDS_INSTR_BRANCH_o;
    assign      IDS_EX_BRANCH_PREDIC_RES_i                  =   IDF_IDS_BRANCH_PREDIC_RES_o;
    assign      IDS_EX_BRANCH_RESERVE_ADDR_i                =   IDF_IDS_BRANCH_RESERVE_ADDR_o;
    assign      IDS_EX_GPR_WRITE_BACK_EN_i                  =   IDF_IDS_GPR_WRITE_BACK_EN_o      ;
    assign      IDS_EX_GPR_WRITE_BACK_ID_i                  =   IDF_IDS_GPR_WRITE_BACK_ID_o      ;
    assign      IDS_EX_GPR_WRITE_BACK_FROM_ALU_i            =   IDF_IDS_GPR_WRITE_BACK_FROM_ALU_o;
    assign      IDS_EX_GPR_WRITE_BACK_FROM_LSU_i            =   IDF_IDS_GPR_WRITE_BACK_FROM_LSU_o;
    assign      IDS_EX_GPR_WRITE_BACK_FROM_MDU_i            =   IDF_IDS_GPR_WRITE_BACK_FROM_MDU_o;
    assign      IDS_EX_DISP_TARGET_i                        =   IDF_IDS_DISP_TARGET_o            ;
    assign      IDS_EX_CSR_WRITE_BACK_EN_i                  =   IDF_IDS_CSR_WRITE_BACK_EN_o      ;
    assign      IDS_EX_CSR_WRITE_BACK_ID_i                  =   IDF_IDS_CSR_WRITE_BACK_ID_o      ;
    assign      IDS_EX_ALU_SHIFT_MODE_i                     =   IDF_IDS_ALU_SHIFT_MODE_o         ;
    assign      IDS_EX_ALU_OP_i                             =   IDF_IDS_ALU_OP_o                 ;
    assign      IDS_EX_MDU_OP_i                             =   IDF_IDS_MDU_OP_o                 ;
    assign      IDS_EX_SHIFT2_i                             =   ids_shift2_o;
    assign      IDS_EX_ADD_RES_L_i                          =   ids_add_res_l_o;
    assign      IDS_EX_ADD_RES_H_i                          =   ids_add_res_h_o;
    assign      IDS_EX_SUB_RES_L_i                          =   ids_sub_res_l_o;   
    assign      IDS_EX_SUB_RES_H_i                          =   ids_sub_res_h_o;
    assign      IDS_EX_SUBU_RES_L_i                         =   ids_subu_res_l_o;
    assign      IDS_EX_SUBU_RES_H_i                         =   ids_subu_res_h_o;
    assign      IDS_EX_OPERAND1_i                           =   ids_operand1_o;
    assign      IDS_EX_OPERAND2_i                           =   ids_operand2_o;
    assign      IDS_EX_RS1_DATA_i                           =   ids_rs1_data_o;
    assign      IDS_EX_RS2_DATA_i                           =   ids_rs2_data_o;
    assign      IDS_EX_JALR_OFFSET_i                        =   IDF_IDS_JALR_OFFSET_o;
    assign      IDS_EX_CSR_DATA_i                           =   ids_csr_data_o;
    IDS_EX                                                              IDS_EX
    (
        .clk                                                            (clk                              ) ,
        .rstn                                                            (rstn                              ) ,
        .flush                                                          (IDS_EX_FLUSH_i                 ) ,
        .stall                                                          (IDS_EX_STALL_i                   ) ,
        .IDS_EX_BUBBLE_FLAG_i                                           (IDS_EX_BUBBLE_FLAG_i             ) ,
        .IDS_EX_ILLEGAL_INSTR_FLAG_i                                    (IDS_EX_ILLEGAL_INSTR_FLAG_i      ) ,
        .IDS_EX_PC_i                                                    (IDS_EX_PC_i                      ) , 
        .IDS_EX_INSTR_i                                                 (IDS_EX_INSTR_i                   ) , 
        .IDS_EX_FUNCT3_i                                                (IDS_EX_FUNCT3_i                  ) ,
        .IDS_EX_INSTR_JALR_i                                            (IDS_EX_INSTR_JALR_i),
        .IDS_EX_INSTR_LOAD_i                                            (IDS_EX_INSTR_LOAD_i              ) ,
        .IDS_EX_INSTR_STORE_i                                           (IDS_EX_INSTR_STORE_i             ) ,
        .IDS_EX_INSTR_SYSTEM_i                                          (IDS_EX_INSTR_SYSTEM_i            ) ,
        .IDS_EX_INSTR_BRANCH_i                                          (IDS_EX_INSTR_BRANCH_i            ) ,
        .IDS_EX_BRANCH_PREDIC_RES_i                                     (IDS_EX_BRANCH_PREDIC_RES_i       ) ,
        .IDS_EX_BRANCH_RESERVE_ADDR_i                                   (IDS_EX_BRANCH_RESERVE_ADDR_i     ) , 
        .IDS_EX_GPR_WRITE_BACK_EN_i                                     (IDS_EX_GPR_WRITE_BACK_EN_i       ) ,
        .IDS_EX_GPR_WRITE_BACK_ID_i                                     (IDS_EX_GPR_WRITE_BACK_ID_i       ) , 
        .IDS_EX_GPR_WRITE_BACK_FROM_ALU_i                               (IDS_EX_GPR_WRITE_BACK_FROM_ALU_i ) ,
        .IDS_EX_GPR_WRITE_BACK_FROM_LSU_i                               (IDS_EX_GPR_WRITE_BACK_FROM_LSU_i ) ,
        .IDS_EX_GPR_WRITE_BACK_FROM_MDU_i                               (IDS_EX_GPR_WRITE_BACK_FROM_MDU_i ) ,
        .IDS_EX_DISP_TARGET_i                                           (IDS_EX_DISP_TARGET_i             ) , 
        .IDS_EX_CSR_WRITE_BACK_EN_i                                     (IDS_EX_CSR_WRITE_BACK_EN_i       ) ,
        .IDS_EX_CSR_WRITE_BACK_ID_i                                     (IDS_EX_CSR_WRITE_BACK_ID_i       ) , 
        .IDS_EX_ALU_SHIFT_MODE_i                                        (IDS_EX_ALU_SHIFT_MODE_i          ) , 
        .IDS_EX_ALU_OP_i                                                (IDS_EX_ALU_OP_i                  ) , 
        .IDS_EX_MDU_OP_i                                                (IDS_EX_MDU_OP_i                  ) ,
        .IDS_EX_SHIFT2_i                                                (IDS_EX_SHIFT2_i),
        .IDS_EX_ADD_RES_L_i                                             (IDS_EX_ADD_RES_L_i ),
        .IDS_EX_ADD_RES_H_i                                             (IDS_EX_ADD_RES_H_i ),
        .IDS_EX_SUB_RES_L_i                                             (IDS_EX_SUB_RES_L_i ),   
        .IDS_EX_SUB_RES_H_i                                             (IDS_EX_SUB_RES_H_i ),
        .IDS_EX_SUBU_RES_L_i                                            (IDS_EX_SUBU_RES_L_i ),
        .IDS_EX_SUBU_RES_H_i                                            (IDS_EX_SUBU_RES_H_i ),
        .IDS_EX_OPERAND1_i                                              (IDS_EX_OPERAND1_i                ) , 
        .IDS_EX_OPERAND2_i                                              (IDS_EX_OPERAND2_i                ) , 
        .IDS_EX_RS1_DATA_i                                              (IDS_EX_RS1_DATA_i                ) , 
        .IDS_EX_RS2_DATA_i                                              (IDS_EX_RS2_DATA_i                ) , 
        .IDS_EX_JALR_OFFSET_i                                           (IDS_EX_JALR_OFFSET_i             ) , 
        .IDS_EX_CSR_DATA_i                                              (IDS_EX_CSR_DATA_i                ) , 
        .IDS_EX_BUBBLE_FLAG_o                                           (IDS_EX_BUBBLE_FLAG_o             ) ,
        .IDS_EX_ILLEGAL_INSTR_FLAG_o                                    (IDS_EX_ILLEGAL_INSTR_FLAG_o      ) ,
        .IDS_EX_PC_o                                                    (IDS_EX_PC_o                      ) , 
        .IDS_EX_FUNCT3_o                                                (IDS_EX_FUNCT3_o                  ) , 
        .IDS_EX_INSTR_o                                                 (IDS_EX_INSTR_o                   ) , 
        .IDS_EX_INSTR_JALR_o                                            (IDS_EX_INSTR_JALR_o),
        .IDS_EX_INSTR_LOAD_o                                            (IDS_EX_INSTR_LOAD_o              ) ,
        .IDS_EX_INSTR_STORE_o                                           (IDS_EX_INSTR_STORE_o             ) ,
        .IDS_EX_INSTR_SYSTEM_o                                          (IDS_EX_INSTR_SYSTEM_o            ) ,
        .IDS_EX_INSTR_BRANCH_o                                          (IDS_EX_INSTR_BRANCH_o            ) ,
        .IDS_EX_BRANCH_PREDIC_RES_o                                     (IDS_EX_BRANCH_PREDIC_RES_o       ) ,
        .IDS_EX_BRANCH_RESERVE_ADDR_o                                   (IDS_EX_BRANCH_RESERVE_ADDR_o     ) , 
        .IDS_EX_GPR_WRITE_BACK_EN_o                                     (IDS_EX_GPR_WRITE_BACK_EN_o       ) ,
        .IDS_EX_GPR_WRITE_BACK_ID_o                                     (IDS_EX_GPR_WRITE_BACK_ID_o       ) , 
        .IDS_EX_GPR_WRITE_BACK_FROM_ALU_o                               (IDS_EX_GPR_WRITE_BACK_FROM_ALU_o ) ,
        .IDS_EX_GPR_WRITE_BACK_FROM_LSU_o                               (IDS_EX_GPR_WRITE_BACK_FROM_LSU_o ) ,
        .IDS_EX_GPR_WRITE_BACK_FROM_MDU_o                               (IDS_EX_GPR_WRITE_BACK_FROM_MDU_o ) ,
        .IDS_EX_CSR_WRITE_BACK_EN_o                                     (IDS_EX_CSR_WRITE_BACK_EN_o       ) ,
        .IDS_EX_CSR_WRITE_BACK_ID_o                                     (IDS_EX_CSR_WRITE_BACK_ID_o       ) , 
        .IDS_EX_DISP_TARGET_o                                           (IDS_EX_DISP_TARGET_o             ) , 
        .IDS_EX_ALU_SHIFT_MODE_o                                        (IDS_EX_ALU_SHIFT_MODE_o          ) , 
        .IDS_EX_ALU_OP_o                                                (IDS_EX_ALU_OP_o                  ) , 
        .IDS_EX_MDU_OP_o                                                (IDS_EX_MDU_OP_o                  ) ,
        .IDS_EX_SHIFT2_o                                                (IDS_EX_SHIFT2_o),
        .IDS_EX_ADD_RES_L_o                                             (IDS_EX_ADD_RES_L_o ),
        .IDS_EX_ADD_RES_H_o                                             (IDS_EX_ADD_RES_H_o ),
        .IDS_EX_SUB_RES_L_o                                             (IDS_EX_SUB_RES_L_o ),   
        .IDS_EX_SUB_RES_H_o                                             (IDS_EX_SUB_RES_H_o ),
        .IDS_EX_SUBU_RES_L_o                                            (IDS_EX_SUBU_RES_L_o),
        .IDS_EX_SUBU_RES_H_o                                            (IDS_EX_SUBU_RES_H_o),
        .IDS_EX_OPERAND1_o                                              (IDS_EX_OPERAND1_o                ) , 
        .IDS_EX_OPERAND2_o                                              (IDS_EX_OPERAND2_o                ) , 
        .IDS_EX_RS1_DATA_o                                              (IDS_EX_RS1_DATA_o                ) , 
        .IDS_EX_RS2_DATA_o                                              (IDS_EX_RS2_DATA_o                ) , 
        .IDS_EX_JALR_OFFSET_o                                           (IDS_EX_JALR_OFFSET_o             ) , 
        .IDS_EX_CSR_DATA_o                                              (IDS_EX_CSR_DATA_o                )   
    );
    //  EXU
    assign      exu_instr_branch_i                  =   IDS_EX_INSTR_BRANCH_o;    
    assign      exu_branch_predic_res_i             =   IDS_EX_BRANCH_PREDIC_RES_o;
    assign      exu_funct3_i                        =   IDS_EX_FUNCT3_o;
    assign      exu_disp_target_i                   =   IDS_EX_DISP_TARGET_o;
    assign      exu_alu_op_i                        =   IDS_EX_ALU_OP_o;
    assign      exu_alu_shift_mode_i                =   IDS_EX_ALU_SHIFT_MODE_o;
    assign      exu_mdu_op_i                        =   IDS_EX_MDU_OP_o;
    assign      exu_shift2_i                        =   IDS_EX_SHIFT2_o;
    assign      exu_add_res_l_i                     =   IDS_EX_ADD_RES_L_o ;
    assign      exu_add_res_h_i                     =   IDS_EX_ADD_RES_H_o ;
    assign      exu_sub_res_l_i                     =   IDS_EX_SUB_RES_L_o ;   
    assign      exu_sub_res_h_i                     =   IDS_EX_SUB_RES_H_o ;
    assign      exu_subu_res_l_i                    =   IDS_EX_SUBU_RES_L_o ;
    assign      exu_subu_res_h_i                    =   IDS_EX_SUBU_RES_H_o ;
    assign      exu_operand1_i                      =   IDS_EX_OPERAND1_o;
    assign      exu_operand2_i                      =   IDS_EX_OPERAND2_o;
    assign      exu_csr_data_i                      =   IDS_EX_CSR_DATA_o;
    exu                                                                 exu
    (
        .exu_instr_branch_i                                             (exu_instr_branch_i        ) ,
        .exu_branch_predic_res_i                                        (exu_branch_predic_res_i   ) ,
        .exu_funct3_i                                                   (exu_funct3_i              ) , 
        .exu_disp_target_i                                              (exu_disp_target_i         ) , 
        .exu_alu_op_i                                                   (exu_alu_op_i              ) , 
        .exu_alu_shift_mode_i                                           (exu_alu_shift_mode_i      ) , 
        .exu_mdu_op_i                                                   (exu_mdu_op_i              ) , 
        .exu_shift2_i                                                   (exu_shift2_i),
        .exu_add_res_l_i                                                (exu_add_res_l_i            ),
        .exu_add_res_h_i                                                (exu_add_res_h_i            ),
        .exu_sub_res_l_i                                                (exu_sub_res_l_i            ),   
        .exu_sub_res_h_i                                                (exu_sub_res_h_i            ),
        .exu_subu_res_l_i                                               (exu_subu_res_l_i           ),
        .exu_subu_res_h_i                                               (exu_subu_res_h_i           ),
        .exu_operand1_i                                                 (exu_operand1_i            ) , 
        .exu_operand2_i                                                 (exu_operand2_i            ) , 
        .exu_csr_data_i                                                 (exu_csr_data_i            ) , 
        .exu_branch_predic_fault_o                                      (exu_branch_predic_fault_o ) ,
        .exu_alu_output_o                                               (exu_alu_output_o          ) ,
        .exu_mdu_output_o                                               (exu_mdu_output_o          ) ,
        .exu_csr_write_back_data_o                                      (exu_csr_write_back_data_o ) 
    );
//--------------------------------------------------EX/MEM
    assign      EX_MEM_FLUSH_i                      =   pcu_EX_MEM_FLUSH_o;
    assign      EX_MEM_STALL_i                      =   pcu_EX_MEM_STALL_o;
    assign      EX_MEM_BUBBLE_FLAG_i                =   IDS_EX_BUBBLE_FLAG_o;
    assign      EX_MEM_ILLEGAL_INSTR_FLAG_i         =   IDS_EX_ILLEGAL_INSTR_FLAG_o;
    assign      EX_MEM_INSTR_i                      =   IDS_EX_INSTR_o;
    assign      EX_MEM_PC_i                         =   IDS_EX_PC_o;
    assign      EX_MEM_FUNCT3_i                     =   IDS_EX_FUNCT3_o;
    assign      EX_MEM_INSTR_LOAD_i                 =   IDS_EX_INSTR_LOAD_o;
    assign      EX_MEM_INSTR_STORE_i                =   IDS_EX_INSTR_STORE_o;
    assign      EX_MEM_INSTR_SYSTEM_i               =   IDS_EX_INSTR_SYSTEM_o;
    assign      EX_MEM_GPR_WRITE_BACK_EN_i          =   IDS_EX_GPR_WRITE_BACK_EN_o;
    assign      EX_MEM_GPR_WRITE_BACK_ID_i          =   IDS_EX_GPR_WRITE_BACK_ID_o;
    assign      EX_MEM_GPR_WRITE_BACK_FROM_ALU_i    =   IDS_EX_GPR_WRITE_BACK_FROM_ALU_o;
    assign      EX_MEM_GPR_WRITE_BACK_FROM_LSU_i    =   IDS_EX_GPR_WRITE_BACK_FROM_LSU_o;
    assign      EX_MEM_GPR_WRITE_BACK_FROM_MDU_i    =   IDS_EX_GPR_WRITE_BACK_FROM_MDU_o;
    assign      EX_MEM_CSR_WRITE_BACK_EN_i          =   IDS_EX_CSR_WRITE_BACK_EN_o;
    assign      EX_MEM_CSR_WRITE_BACK_ID_i          =   IDS_EX_CSR_WRITE_BACK_ID_o;
    assign      EX_MEM_RS2_DATA_i                   =   IDS_EX_RS2_DATA_o;
    assign      EX_MEM_ALU_OUTPUT_i                 =   exu_alu_output_o;
    assign      EX_MEM_MDU_OUTPUT_i                 =   exu_mdu_output_o;
    assign      EX_MEM_CSR_WRITE_BACK_DATA_i        =   exu_csr_write_back_data_o;
    EX_MEM                                                              EX_MEM
    (
        .clk                                                            (clk                          ) ,
        .rstn                                                            (rstn                          ) ,
        .flush                                                          (EX_MEM_FLUSH_i               ) ,
        .stall                                                          (EX_MEM_STALL_i               ) ,
        .EX_MEM_BUBBLE_FLAG_i                                           (EX_MEM_BUBBLE_FLAG_i         ) ,
        .EX_MEM_ILLEGAL_INSTR_FLAG_i                                    (EX_MEM_ILLEGAL_INSTR_FLAG_i  ) ,
        .EX_MEM_INSTR_i                                                 (EX_MEM_INSTR_i               ) , 
        .EX_MEM_PC_i                                                    (EX_MEM_PC_i                  ) , 
        .EX_MEM_FUNCT3_i                                                (EX_MEM_FUNCT3_i              ) , 
        .EX_MEM_INSTR_LOAD_i                                            (EX_MEM_INSTR_LOAD_i          ) ,
        .EX_MEM_INSTR_STORE_i                                           (EX_MEM_INSTR_STORE_i         ) ,
        .EX_MEM_INSTR_SYSTEM_i                                          (EX_MEM_INSTR_SYSTEM_i        ) ,
        .EX_MEM_GPR_WRITE_BACK_EN_i                                     (EX_MEM_GPR_WRITE_BACK_EN_i   ) ,
        .EX_MEM_GPR_WRITE_BACK_ID_i                                     (EX_MEM_GPR_WRITE_BACK_ID_i   ) ,
        .EX_MEM_GPR_WRITE_BACK_FROM_ALU_i                               (EX_MEM_GPR_WRITE_BACK_FROM_ALU_i),
        .EX_MEM_GPR_WRITE_BACK_FROM_LSU_i                               (EX_MEM_GPR_WRITE_BACK_FROM_LSU_i),
        .EX_MEM_GPR_WRITE_BACK_FROM_MDU_i                               (EX_MEM_GPR_WRITE_BACK_FROM_MDU_i), 
        .EX_MEM_CSR_WRITE_BACK_EN_i                                     (EX_MEM_CSR_WRITE_BACK_EN_i   ) ,
        .EX_MEM_CSR_WRITE_BACK_ID_i                                     (EX_MEM_CSR_WRITE_BACK_ID_i   ) , 
        .EX_MEM_RS2_DATA_i                                              (EX_MEM_RS2_DATA_i),
        .EX_MEM_ALU_OUTPUT_i                                            (EX_MEM_ALU_OUTPUT_i          ) , 
        .EX_MEM_MDU_OUTPUT_i                                            (EX_MEM_MDU_OUTPUT_i          ) , 
        .EX_MEM_CSR_WRITE_BACK_DATA_i                                   (EX_MEM_CSR_WRITE_BACK_DATA_i ) , 
        .EX_MEM_BUBBLE_FLAG_o                                           (EX_MEM_BUBBLE_FLAG_o         ) ,
        .EX_MEM_ILLEGAL_INSTR_FLAG_o                                    (EX_MEM_ILLEGAL_INSTR_FLAG_o  ) ,
        .EX_MEM_INSTR_o                                                 (EX_MEM_INSTR_o               ) , 
        .EX_MEM_PC_o                                                    (EX_MEM_PC_o                  ) , 
        .EX_MEM_FUNCT3_o                                                (EX_MEM_FUNCT3_o              ) , 
        .EX_MEM_INSTR_LOAD_o                                            (EX_MEM_INSTR_LOAD_o          ) ,
        .EX_MEM_INSTR_STORE_o                                           (EX_MEM_INSTR_STORE_o         ) ,
        .EX_MEM_INSTR_SYSTEM_o                                          (EX_MEM_INSTR_SYSTEM_o        ) ,
        .EX_MEM_GPR_WRITE_BACK_EN_o                                     (EX_MEM_GPR_WRITE_BACK_EN_o   ) ,
        .EX_MEM_GPR_WRITE_BACK_ID_o                                     (EX_MEM_GPR_WRITE_BACK_ID_o   ) , 
        .EX_MEM_GPR_WRITE_BACK_FROM_ALU_o                               (EX_MEM_GPR_WRITE_BACK_FROM_ALU_o),
        .EX_MEM_GPR_WRITE_BACK_FROM_LSU_o                               (EX_MEM_GPR_WRITE_BACK_FROM_LSU_o),
        .EX_MEM_GPR_WRITE_BACK_FROM_MDU_o                               (EX_MEM_GPR_WRITE_BACK_FROM_MDU_o),
        .EX_MEM_CSR_WRITE_BACK_EN_o                                     (EX_MEM_CSR_WRITE_BACK_EN_o   ) ,
        .EX_MEM_CSR_WRITE_BACK_ID_o                                     (EX_MEM_CSR_WRITE_BACK_ID_o   ) ,
        .EX_MEM_RS2_DATA_o                                              (EX_MEM_RS2_DATA_o),
        .EX_MEM_ALU_OUTPUT_o                                            (EX_MEM_ALU_OUTPUT_o          ) , 
        .EX_MEM_MDU_OUTPUT_o                                            (EX_MEM_MDU_OUTPUT_o          ) , 
        .EX_MEM_CSR_WRITE_BACK_DATA_o                                   (EX_MEM_CSR_WRITE_BACK_DATA_o )   
    );
//-----------------------------------MEM-----------------------------------------------------
    //  edu
    assign      edu_pc_i                                   =   EX_MEM_PC_o[01:00];
    assign      edu_instr_i                                =   EX_MEM_INSTR_o; 
    assign      edu_funct3_i                               =   EX_MEM_FUNCT3_o;      
    assign      edu_instr_load_i                           =   EX_MEM_INSTR_LOAD_o;
    assign      edu_instr_store_i                          =   EX_MEM_INSTR_STORE_o;
    assign      edu_instr_system_i                         =   EX_MEM_INSTR_SYSTEM_o;
    assign      edu_mem_addr_i                             =   EX_MEM_ALU_OUTPUT_o[02:00];
    assign      edu_illegal_instr_flag_i                   =   EX_MEM_ILLEGAL_INSTR_FLAG_o;
    assign      edu_instr_acc_fault_i                      =   1'b0;
    assign      edu_load_acc_fault_i                       =   1'b0;
    assign      edu_store_acc_fault_i                      =   1'b0;

    edu                                                                edu
    (
        .edu_instr_i                                                   (edu_instr_i                 ) ,
        .edu_pc_i                                                      (edu_pc_i               ) , 
        .edu_funct3_i                                                  (edu_funct3_i               ) ,
        .edu_instr_system_i                                            (edu_instr_system_i          ) ,
        .edu_instr_load_i                                              (edu_instr_load_i            ) ,
        .edu_instr_store_i                                             (edu_instr_store_i           ) ,
        .edu_mem_addr_i                                                (edu_mem_addr_i              ) ,
        .edu_instr_acc_fault_i                                         (edu_instr_acc_fault_i    ) ,
        .edu_illegal_instr_flag_i                                      (edu_illegal_instr_flag_i    ) ,
        .edu_load_acc_fault_i                                          (edu_load_acc_fault_i        ) ,
        .edu_store_acc_fault_i                                         (edu_store_acc_fault_i       ) ,
        .edu_instr_addr_misalig_o                                      (edu_instr_addr_misalig_o  ),
        .edu_instr_acc_fault_o                                         (edu_instr_acc_fault_o     ),
        .edu_illegal_instr_o                                           (edu_illegal_instr_o       ),
        .edu_ebreak_o                                                  (edu_ebreak_o              ),
        .edu_load_addr_misalig_o                                       (edu_load_addr_misalig_o   ),
        .edu_load_acc_fault_o                                          (edu_load_acc_fault_o      ),
        .edu_store_addr_misalig_o                                      (edu_store_addr_misalig_o  ),
        .edu_store_acc_fault_o                                         (edu_store_acc_fault_o     ),
        .edu_ecall_o                                                   (edu_ecall_o               ),
        .edu_mret_flag_o                                               (edu_mret_flag_o             ), 
        .edu_wfi_flag_o                                                (edu_wfi_flag_o              ) ,
        .edu_exc_flag_o                                                (edu_exc_flag_o                )
    );
    //  LSU
    assign      lsu_flush_i                     =   pcu_EX_MEM_FLUSH_o;
    assign      lsu_exc_irq_flag_i              =   wbu_exc_irq_flag_o;
    assign      lsu_instr_load_i                =   EX_MEM_INSTR_LOAD_o;
    assign      lsu_instr_store_i               =   EX_MEM_INSTR_STORE_o;
    assign      lsu_funct3_i                    =   EX_MEM_FUNCT3_o;
    assign      lsu_mem_addr_i                  =   EX_MEM_ALU_OUTPUT_o;
    assign      lsu_store_data_i                =   EX_MEM_RS2_DATA_o;
    lsu                                                                 lsu
    (
        .clk                                                            (clk               ) ,
        .rstn                                                            (rstn               ) ,
        .flush                                                          (lsu_flush_i),
        .lsu_exc_irq_flag_i                                             (lsu_exc_irq_flag_i),
        .lsu_instr_load_i                                               (lsu_instr_load_i  ) ,
        .lsu_instr_store_i                                              (lsu_instr_store_i ) ,
        .lsu_funct3_i                                                   (lsu_funct3_i      ) , 
        .lsu_mem_addr_i                                                 (lsu_mem_addr_i    ) , 
        .lsu_store_data_i                                               (lsu_store_data_i  ) , 
        .lsu_done_o                                                     (lsu_done_o        ) ,
        .lsu_flag_o                                                     (lsu_flag_o        ) ,
        .lsu_byte_en_o                                                  (byte_en),
        .lsu_load_data_o                                                (lsu_load_data_o   ) , 
        .WB_ACKi                                                        (WB_ACKi           ) ,
        .WB_DATi                                                        (WB_DATi           ) , 
        .WB_ADRo                                                        (WB_ADRo           ) , 
        .WB_DATo                                                        (WB_DATo           ) , 
        .WB_WEo                                                         (WB_WEo            ) ,
        .WB_CYCo                                                        (WB_CYCo           )  
    );

    //  MEM_WB


    assign      MEM_WB_FLUSH_i                      =   pcu_MEM_WB_FLUSH_o;
    assign      MEM_WB_STALL_i                      =   pcu_MEM_WB_STALL_o;
    assign      MEM_WB_BUBBLE_FLAG_i                =   EX_MEM_BUBBLE_FLAG_o;
    assign      MEM_WB_INSTR_i                      =   EX_MEM_INSTR_o;
    assign      MEM_WB_PC_i                         =   EX_MEM_PC_o;
    assign      MEM_WB_GPR_WRITE_BACK_EN_i          =   EX_MEM_GPR_WRITE_BACK_EN_o;
    assign      MEM_WB_GPR_WRITE_BACK_ID_i          =   EX_MEM_GPR_WRITE_BACK_ID_o;
    assign      MEM_WB_GPR_WRITE_BACK_FROM_ALU_i    =   EX_MEM_GPR_WRITE_BACK_FROM_ALU_o;
    assign      MEM_WB_GPR_WRITE_BACK_FROM_LSU_i    =   EX_MEM_GPR_WRITE_BACK_FROM_LSU_o;
    assign      MEM_WB_GPR_WRITE_BACK_FROM_MDU_i    =   EX_MEM_GPR_WRITE_BACK_FROM_MDU_o;
    assign      MEM_WB_CSR_WRITE_BACK_EN_i          =   EX_MEM_CSR_WRITE_BACK_EN_o;
    assign      MEM_WB_CSR_WRITE_BACK_ID_i          =   EX_MEM_CSR_WRITE_BACK_ID_o;
    assign      MEM_WB_ALU_OUTPUT_i                 =   EX_MEM_ALU_OUTPUT_o;
    assign      MEM_WB_LSU_OUTPUT_i                 =   lsu_load_data_o ;
    assign      MEM_WB_MDU_OUTPUT_i                 =   EX_MEM_MDU_OUTPUT_o;
    assign      MEM_WB_CSR_WRITE_BACK_DATA_i        =   EX_MEM_CSR_WRITE_BACK_DATA_o;
    assign      MEM_WB_INSTR_ADDR_MISALIG_i         =   edu_instr_addr_misalig_o;
    assign      MEM_WB_INSTR_ACC_FAULT_i            =   edu_instr_acc_fault_o   ;
    assign      MEM_WB_ILLEGAL_INSTR_i              =   edu_illegal_instr_o     ;
    assign      MEM_WB_EBREAK_i                     =   edu_ebreak_o            ;
    assign      MEM_WB_LOAD_ADDR_MISALIG_i          =   edu_load_addr_misalig_o ;
    assign      MEM_WB_LOAD_ACC_FAULT_i             =   edu_load_acc_fault_o    ;
    assign      MEM_WB_STORE_ADDR_MISALIG_i         =   edu_store_addr_misalig_o;
    assign      MEM_WB_STORE_ACC_FAULT_i            =   edu_store_acc_fault_o   ;
    assign      MEM_WB_ECALL_i                      =   edu_ecall_o             ;
    assign      MEM_WB_MRET_FLAG_i                  =   edu_mret_flag_o         ;
    assign      MEM_WB_WFI_FLAG_i                   =   edu_wfi_flag_o          ;
    assign      MEM_WB_EXC_FLAG_i                   =   edu_exc_flag_o          ;
    assign      MEM_WB_MEI_i                        =   mei;
    assign      MEM_WB_MSI_i                        =   msi;
    assign      MEM_WB_MTI_i                        =   mti;
            
    MEM_WB                                                              MEM_WB(
        .clk                                                            (clk                         ) ,
        .rstn                                                           (rstn                         ) ,
        .flush                                                          (MEM_WB_FLUSH_i                ) ,
        .stall                                                          (MEM_WB_STALL_i                 ) ,
        .MEM_WB_BUBBLE_FLAG_i                                           (MEM_WB_BUBBLE_FLAG_i             ) ,
        .MEM_WB_INSTR_i                                                 (MEM_WB_INSTR_i),
        .MEM_WB_PC_i                                                    (MEM_WB_PC_i),
        .MEM_WB_GPR_WRITE_BACK_EN_i                                     (MEM_WB_GPR_WRITE_BACK_EN_i       ) ,
        .MEM_WB_GPR_WRITE_BACK_ID_i                                     (MEM_WB_GPR_WRITE_BACK_ID_i       ) , 
        .MEM_WB_GPR_WRITE_BACK_FROM_ALU_i                               (MEM_WB_GPR_WRITE_BACK_FROM_ALU_i ) ,
        .MEM_WB_GPR_WRITE_BACK_FROM_LSU_i                               (MEM_WB_GPR_WRITE_BACK_FROM_LSU_i ) ,
        .MEM_WB_GPR_WRITE_BACK_FROM_MDU_i                               (MEM_WB_GPR_WRITE_BACK_FROM_MDU_i ) ,
        .MEM_WB_CSR_WRITE_BACK_EN_i                                     (MEM_WB_CSR_WRITE_BACK_EN_i       ) ,
        .MEM_WB_CSR_WRITE_BACK_ID_i                                     (MEM_WB_CSR_WRITE_BACK_ID_i       ) , 
        .MEM_WB_ALU_OUTPUT_i                                            (MEM_WB_ALU_OUTPUT_i              ) , 
        .MEM_WB_LSU_OUTPUT_i                                            (MEM_WB_LSU_OUTPUT_i              ) , 
        .MEM_WB_MDU_OUTPUT_i                                            (MEM_WB_MDU_OUTPUT_i              ) , 
        .MEM_WB_CSR_WRITE_BACK_DATA_i                                   (MEM_WB_CSR_WRITE_BACK_DATA_i     ) , 
        .MEM_WB_INSTR_ADDR_MISALIG_i                                    (MEM_WB_INSTR_ADDR_MISALIG_i      ) ,
        .MEM_WB_INSTR_ACC_FAULT_i                                       (MEM_WB_INSTR_ACC_FAULT_i         ) ,
        .MEM_WB_ILLEGAL_INSTR_i                                         (MEM_WB_ILLEGAL_INSTR_i           ) ,
        .MEM_WB_EBREAK_i                                                (MEM_WB_EBREAK_i                  ) ,
        .MEM_WB_LOAD_ADDR_MISALIG_i                                     (MEM_WB_LOAD_ADDR_MISALIG_i       ) ,
        .MEM_WB_LOAD_ACC_FAULT_i                                        (MEM_WB_LOAD_ACC_FAULT_i          ) ,
        .MEM_WB_STORE_ADDR_MISALIG_i                                    (MEM_WB_STORE_ADDR_MISALIG_i      ) ,
        .MEM_WB_STORE_ACC_FAULT_i                                       (MEM_WB_STORE_ACC_FAULT_i         ) ,
        .MEM_WB_ECALL_i                                                 (MEM_WB_ECALL_i                   ) ,
        .MEM_WB_MRET_FLAG_i                                             (MEM_WB_MRET_FLAG_i               ) ,
        .MEM_WB_WFI_FLAG_i                                              (MEM_WB_WFI_FLAG_i                ) ,
        .MEM_WB_EXC_FLAG_i                                              (MEM_WB_EXC_FLAG_i                ) ,
        .MEM_WB_MEI_i                                                   (MEM_WB_MEI_i),
        .MEM_WB_MSI_i                                                   (MEM_WB_MSI_i),
        .MEM_WB_MTI_i                                                   (MEM_WB_MTI_i) ,
        .MEM_WB_BUBBLE_FLAG_o                                           (MEM_WB_BUBBLE_FLAG_o             ) ,
        .MEM_WB_INSTR_o                                                 (MEM_WB_INSTR_o),
        .MEM_WB_PC_o                                                    (MEM_WB_PC_o),
        .MEM_WB_GPR_WRITE_BACK_EN_o                                     (MEM_WB_GPR_WRITE_BACK_EN_o       ) ,
        .MEM_WB_GPR_WRITE_BACK_ID_o                                     (MEM_WB_GPR_WRITE_BACK_ID_o       ) , 
        .MEM_WB_GPR_WRITE_BACK_FROM_ALU_o                               (MEM_WB_GPR_WRITE_BACK_FROM_ALU_o ) ,
        .MEM_WB_GPR_WRITE_BACK_FROM_LSU_o                               (MEM_WB_GPR_WRITE_BACK_FROM_LSU_o ) ,
        .MEM_WB_GPR_WRITE_BACK_FROM_MDU_o                               (MEM_WB_GPR_WRITE_BACK_FROM_MDU_o ) ,
        .MEM_WB_CSR_WRITE_BACK_EN_o                                     (MEM_WB_CSR_WRITE_BACK_EN_o       ) ,
        .MEM_WB_CSR_WRITE_BACK_ID_o                                     (MEM_WB_CSR_WRITE_BACK_ID_o       ) , 
        .MEM_WB_ALU_OUTPUT_o                                            (MEM_WB_ALU_OUTPUT_o              ) , 
        .MEM_WB_LSU_OUTPUT_o                                            (MEM_WB_LSU_OUTPUT_o              ) , 
        .MEM_WB_MDU_OUTPUT_o                                            (MEM_WB_MDU_OUTPUT_o              ) , 
        .MEM_WB_CSR_WRITE_BACK_DATA_o                                   (MEM_WB_CSR_WRITE_BACK_DATA_o     ) , 
        .MEM_WB_INSTR_ADDR_MISALIG_o                                    (MEM_WB_INSTR_ADDR_MISALIG_o      ) ,
        .MEM_WB_INSTR_ACC_FAULT_o                                       (MEM_WB_INSTR_ACC_FAULT_o         ) ,
        .MEM_WB_ILLEGAL_INSTR_o                                         (MEM_WB_ILLEGAL_INSTR_o           ) ,
        .MEM_WB_EBREAK_o                                                (MEM_WB_EBREAK_o                  ) ,
        .MEM_WB_LOAD_ADDR_MISALIG_o                                     (MEM_WB_LOAD_ADDR_MISALIG_o       ) ,
        .MEM_WB_LOAD_ACC_FAULT_o                                        (MEM_WB_LOAD_ACC_FAULT_o          ) ,
        .MEM_WB_STORE_ADDR_MISALIG_o                                    (MEM_WB_STORE_ADDR_MISALIG_o      ) ,
        .MEM_WB_STORE_ACC_FAULT_o                                       (MEM_WB_STORE_ACC_FAULT_o         ) ,
        .MEM_WB_ECALL_o                                                 (MEM_WB_ECALL_o                   ) ,
        .MEM_WB_MRET_FLAG_o                                             (MEM_WB_MRET_FLAG_o               ) ,
        .MEM_WB_WFI_FLAG_o                                              (MEM_WB_WFI_FLAG_o                ) ,
        .MEM_WB_EXC_FLAG_o                                              (MEM_WB_EXC_FLAG_o                ) ,
        .MEM_WB_MEI_o                                                   (MEM_WB_MEI_o),
        .MEM_WB_MSI_o                                                   (MEM_WB_MSI_o),
        .MEM_WB_MTI_o                                                   (MEM_WB_MTI_o) 
);

    //  WBU
    //  exc csr
    assign      wbu_mstatus_i                       =   csr_mstatus_o;
    assign      wbu_mie_i                           =   csr_mie_o;
    assign      wbu_mtvec_i                         =   csr_mtvec_o;
    assign      wbu_gpr_write_back_en_i             =   MEM_WB_GPR_WRITE_BACK_EN_o;
    assign      wbu_gpr_write_back_id_i             =   MEM_WB_GPR_WRITE_BACK_ID_o;
        
    assign      wbu_gpr_write_back_from_alu_i       =   MEM_WB_GPR_WRITE_BACK_FROM_ALU_o;
    assign      wbu_gpr_write_back_from_lsu_i       =   MEM_WB_GPR_WRITE_BACK_FROM_LSU_o;
    assign      wbu_gpr_write_back_from_mdu_i       =   MEM_WB_GPR_WRITE_BACK_FROM_MDU_o;
    assign      wbu_alu_output_i                    =   MEM_WB_ALU_OUTPUT_o ;
    assign      wbu_lsu_output_i                    =   MEM_WB_LSU_OUTPUT_o ;
    assign      wbu_mdu_output_i                    =   MEM_WB_MDU_OUTPUT_o ;
    assign      wbu_csr_write_back_en_i             =   MEM_WB_CSR_WRITE_BACK_EN_o;
    assign      wbu_csr_write_back_id_i             =   MEM_WB_CSR_WRITE_BACK_ID_o;
    assign      wbu_csr_write_back_data_i           =   MEM_WB_CSR_WRITE_BACK_DATA_o;
    assign      wbu_mei_flag_i                      =   MEM_WB_MEI_o;
    assign      wbu_msi_flag_i                      =   MEM_WB_MSI_o;
    assign      wbu_mti_flag_i                      =   MEM_WB_MTI_o;
    assign      wbu_instr_addr_misalig_i            =   MEM_WB_INSTR_ADDR_MISALIG_o;
    assign      wbu_instr_acc_fault_i               =   MEM_WB_INSTR_ACC_FAULT_o   ;
    assign      wbu_illegal_instr_i                 =   MEM_WB_ILLEGAL_INSTR_o     ;
    assign      wbu_ebreak_i                        =   MEM_WB_EBREAK_o            ;
    assign      wbu_load_addr_misalig_i             =   MEM_WB_LOAD_ADDR_MISALIG_o ;
    assign      wbu_load_acc_fault_i                =   MEM_WB_LOAD_ACC_FAULT_o    ;
    assign      wbu_store_addr_misalig_i            =   MEM_WB_STORE_ADDR_MISALIG_o;
    assign      wbu_store_acc_fault_i               =   MEM_WB_STORE_ACC_FAULT_o   ;
    assign      wbu_ecall_i                         =   MEM_WB_ECALL_o             ;
    assign      wbu_mret_flag_i                     =   MEM_WB_MRET_FLAG_o         ;
    assign      wbu_wfi_flag_i                      =   MEM_WB_WFI_FLAG_o          ;
    assign      wbu_exc_flag_i                      =   MEM_WB_EXC_FLAG_o          ;

    wbu                                                                 wbu
    (
        .wbu_mei_flag_i                                                 (wbu_mei_flag_i                ) ,
        .wbu_msi_flag_i                                                 (wbu_msi_flag_i                ) ,
        .wbu_mti_flag_i                                                 (wbu_mti_flag_i                ) ,
        .wbu_mstatus_i                                                  (wbu_mstatus_i),
        .wbu_mie_i                                                      (wbu_mie_i),
        .wbu_mtvec_i                                                    (wbu_mtvec_i),
        .wbu_instr_addr_misalig_i                                       (wbu_instr_addr_misalig_i      ) ,
        .wbu_instr_acc_fault_i                                          (wbu_instr_acc_fault_i         ) ,
        .wbu_illegal_instr_i                                            (wbu_illegal_instr_i           ) ,
        .wbu_ebreak_i                                                   (wbu_ebreak_i                  ) ,
        .wbu_load_addr_misalig_i                                        (wbu_load_addr_misalig_i       ) ,
        .wbu_load_acc_fault_i                                           (wbu_load_acc_fault_i          ) ,
        .wbu_store_addr_misalig_i                                       (wbu_store_addr_misalig_i      ) ,
        .wbu_store_acc_fault_i                                          (wbu_store_acc_fault_i         ) ,
        .wbu_ecall_i                                                    (wbu_ecall_i                   ) ,
        .wbu_mret_flag_i                                                (wbu_mret_flag_i               ) ,
        .wbu_wfi_flag_i                                                 (wbu_wfi_flag_i                ) ,
        .wbu_exc_flag_i                                                 (wbu_exc_flag_i                ) ,
        .wbu_alu_output_i                                               (wbu_alu_output_i              ) , 
        .wbu_lsu_output_i                                               (wbu_lsu_output_i              ) , 
        .wbu_mdu_output_i                                               (wbu_mdu_output_i              ) , 
        .wbu_gpr_write_back_en_i                                        (wbu_gpr_write_back_en_i       ) ,
        .wbu_gpr_write_back_id_i                                        (wbu_gpr_write_back_id_i       ) , 
        .wbu_gpr_write_back_from_alu_i                                  (wbu_gpr_write_back_from_alu_i ) ,
        .wbu_gpr_write_back_from_lsu_i                                  (wbu_gpr_write_back_from_lsu_i ) ,
        .wbu_gpr_write_back_from_mdu_i                                  (wbu_gpr_write_back_from_mdu_i ) ,
        .wbu_csr_write_back_en_i                                        (wbu_csr_write_back_en_i       ) ,
        .wbu_csr_write_back_id_i                                        (wbu_csr_write_back_id_i       ) , 
        .wbu_csr_write_back_data_i                                      (wbu_csr_write_back_data_i     ) , 
        .wbu_mei_flag_o                                                 (wbu_mei_flag_o                ) ,
        .wbu_msi_flag_o                                                 (wbu_msi_flag_o                ) ,
        .wbu_mti_flag_o                                                 (wbu_mti_flag_o                ) ,
        .wbu_irq_flag_o                                                 (wbu_irq_flag_o                ) ,
        .wbu_instr_addr_misalig_o                                       (wbu_instr_addr_misalig_o      ) ,
        .wbu_instr_acc_fault_o                                          (wbu_instr_acc_fault_o         ) ,
        .wbu_illegal_instr_o                                            (wbu_illegal_instr_o           ) ,
        .wbu_ebreak_o                                                   (wbu_ebreak_o                  ) ,
        .wbu_load_addr_misalig_o                                        (wbu_load_addr_misalig_o       ) ,
        .wbu_load_acc_fault_o                                           (wbu_load_acc_fault_o          ) ,
        .wbu_store_addr_misalig_o                                       (wbu_store_addr_misalig_o      ) ,
        .wbu_store_acc_fault_o                                          (wbu_store_acc_fault_o         ) ,
        .wbu_ecall_o                                                    (wbu_ecall_o                   ) ,
        .wbu_mret_flag_o                                                (wbu_mret_flag_o               ) ,
        .wbu_wfi_flag_o                                                 (wbu_wfi_flag_o                ) ,
        .wbu_exc_flag_o                                                 (wbu_exc_flag_o                ) ,
        .wbu_exc_irq_flag_o                                             (wbu_exc_irq_flag_o            ) ,
        .wbu_exc_irq_srv_prog_addr_o                                    (wbu_exc_irq_srv_prog_addr_o    ),
        .wbu_gpr_write_back_en_o                                        (wbu_gpr_write_back_en_o       ) ,
        .wbu_gpr_write_back_id_o                                        (wbu_gpr_write_back_id_o       ) , 
        .wbu_csr_write_back_en_o                                        (wbu_csr_write_back_en_o       ) ,
        .wbu_csr_write_back_id_o                                        (wbu_csr_write_back_id_o       ) , 
        .wbu_gpr_write_back_data_o                                      (wbu_gpr_write_back_data_o     ) , 
        .wbu_csr_write_back_data_o                                      (wbu_csr_write_back_data_o     ) 

    );

endmodule